Admin Dashboard, Hilfe-Seite, Dockerfile Fixes (gunicorn, UID 1000, HOME)

This commit is contained in:
Erik Thiele
2026-06-21 16:46:06 +02:00
parent 9ccbd1d896
commit 928ea92aed
2 changed files with 27 additions and 11 deletions

33
app.py
View File

@@ -54,11 +54,14 @@ login_manager.login_view = "login" # Nicht eingeloggte User werden zum Login um
# Config-Helfer
# -------------------------------------------------
def load_config():
"""Liest die config.json und gibt das Dict zurück. Legt ein leeres an, falls nicht vorhanden."""
"""Liest die config.json und gibt das Dict zurück. Legt ein leeres an, falls nicht vorhanden oder fehlerhaft."""
if not os.path.exists(CONFIG_FILE):
return {"admin": {}, "sites": {}}
with open(CONFIG_FILE) as f:
return json.load(f)
try:
with open(CONFIG_FILE) as f:
return json.load(f)
except (json.JSONDecodeError, OSError):
return {"admin": {}, "sites": {}}
def save_config(cfg):
@@ -295,11 +298,14 @@ class User(UserMixin):
def load_users():
"""Liest die users.json. Gibt leeres Dict zurück, wenn nicht vorhanden."""
"""Liest die users.json. Gibt leeres Dict zurück, wenn nicht vorhanden oder fehlerhaft."""
if not os.path.exists(USERS_FILE):
return {}
with open(USERS_FILE) as f:
return json.load(f)
try:
with open(USERS_FILE) as f:
return json.load(f)
except (json.JSONDecodeError, OSError):
return {}
def save_users(users):
@@ -318,9 +324,15 @@ def get_user(email):
def init_user_db():
"""Legt users.json mit einem Admin-Konto aus config.json.admin an, falls sie nicht existiert."""
"""Legt users.json mit einem Admin-Konto aus config.json.admin an, falls sie nicht existiert oder leer ist."""
if os.path.exists(USERS_FILE):
return
try:
with open(USERS_FILE) as f:
content = f.read().strip()
if content:
return
except OSError:
pass
cfg = load_config()
admin = cfg.get("admin", {})
username = admin.get("username", "admin@signage.local")
@@ -1584,7 +1596,10 @@ def admin_users_reset_password(email):
# -------------------------------------------------
# Main
# -------------------------------------------------
init_user_db()
try:
init_user_db()
except Exception as e:
print(f"⚠️ init_user_db fehlgeschlagen: {e}")
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port=5005)