Logging in App.py
This commit is contained in:
+7
-4
@@ -34,12 +34,15 @@ def ist_konfiguriert():
|
|||||||
def versuche_verbindung_mit_warten():
|
def versuche_verbindung_mit_warten():
|
||||||
elapsed = 0
|
elapsed = 0
|
||||||
if not ist_konfiguriert():
|
if not ist_konfiguriert():
|
||||||
|
logger.warning("⚠️ Noch keine Konfiguration gefunden.")
|
||||||
return False
|
return False
|
||||||
config = lade_db_config()
|
config = lade_db_config()
|
||||||
while not teste_verbindung(config) and elapsed < MAX_WAIT:
|
while not teste_verbindung(config) and elapsed < MAX_WAIT:
|
||||||
print(f"[INFO] DB nicht erreichbar – warte {WAIT_INTERVAL}s...")
|
logger.info(f"🔄 DB nicht erreichbar – warte {WAIT_INTERVAL}s...")
|
||||||
time.sleep(WAIT_INTERVAL)
|
time.sleep(WAIT_INTERVAL)
|
||||||
elapsed += WAIT_INTERVAL
|
elapsed += WAIT_INTERVAL
|
||||||
|
if elapsed >= MAX_WAIT:
|
||||||
|
logger.error("❌ Maximale Wartezeit überschritten – DB nicht erreichbar.")
|
||||||
return elapsed < MAX_WAIT
|
return elapsed < MAX_WAIT
|
||||||
|
|
||||||
@app.route('/api/status')
|
@app.route('/api/status')
|
||||||
@@ -63,10 +66,11 @@ def setup():
|
|||||||
}
|
}
|
||||||
speichere_db_config(db_config)
|
speichere_db_config(db_config)
|
||||||
if teste_verbindung(db_config):
|
if teste_verbindung(db_config):
|
||||||
initialisiere_admin_user(db_config) # <- das hier NEU
|
initialisiere_admin_user(db_config)
|
||||||
|
logger.info("✅ Setup erfolgreich, Admin-User erstellt.")
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
logger.error("❌ Setup fehlgeschlagen – DB-Verbindung nicht möglich.")
|
||||||
return "Verbindung fehlgeschlagen. Bitte zurück und prüfen.", 500
|
return "Verbindung fehlgeschlagen. Bitte zurück und prüfen.", 500
|
||||||
return render_template('setup.html')
|
return render_template('setup.html')
|
||||||
|
|
||||||
@@ -131,7 +135,6 @@ def login():
|
|||||||
|
|
||||||
@app.route('/api/logout', methods=['POST'])
|
@app.route('/api/logout', methods=['POST'])
|
||||||
def logout():
|
def logout():
|
||||||
# Aktuell macht das nichts, aber der Client bekommt Bestätigung
|
|
||||||
return jsonify({"message": "Logout erfolgreich"})
|
return jsonify({"message": "Logout erfolgreich"})
|
||||||
|
|
||||||
def verify_token():
|
def verify_token():
|
||||||
|
|||||||
Reference in New Issue
Block a user