fix: test connection reads form values instead of saved config
The "Kapcsolat tesztelése" button sent an empty POST to /settings/test, which read from the (possibly empty) config file on disk. Now sends the current form values so testing works before clicking Save. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-4
@@ -50,12 +50,13 @@ def settings():
|
||||
|
||||
@app.route("/settings/test", methods=["POST"])
|
||||
def settings_test():
|
||||
"""AJAX endpoint — test Mealie connection."""
|
||||
cfg = config.load()
|
||||
if not cfg.get("mealie_url") or not cfg.get("mealie_api_key"):
|
||||
"""AJAX endpoint — test Mealie connection using form values."""
|
||||
url = (request.form.get("mealie_url") or "").strip().rstrip("/")
|
||||
key = (request.form.get("mealie_api_key") or "").strip()
|
||||
if not url or not key:
|
||||
return jsonify({"ok": False, "error": "Nincs megadva Mealie URL vagy API kulcs."})
|
||||
try:
|
||||
client = MealieClient(cfg["mealie_url"], cfg["mealie_api_key"])
|
||||
client = MealieClient(url, key)
|
||||
info = client.test_connection()
|
||||
return jsonify({"ok": True, "data": info})
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user