From 2fc24afcb9f1c074635083659ad7e8be77516132 Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:24:57 +0200 Subject: [PATCH] modified: app.py --- app.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index d7b5224..f992d74 100644 --- a/app.py +++ b/app.py @@ -68,12 +68,6 @@ def get_db_connection(): database=DB_NAME ) -@app.route("/") -def index(): - if "username" in session: - return render_template("index.html", bot_running=bot_status(), theme=session.get('theme', 'light')) - return redirect(url_for("login")) - @app.route("/login", methods=["GET", "POST"]) def login(): if request.method == "POST": @@ -129,18 +123,30 @@ def settings(): return render_template("settings.html", introduction=introduction, asknotes_introduction=asknotes_introduction, theme=session.get('theme', 'light')) return redirect(url_for("login")) +@app.route("/") +def index(): + if "username" in session: + # Sicherstellen, dass das Theme gesetzt ist + if 'theme' not in session: + session['theme'] = 'light' # Standard-Theme setzen + return render_template("index.html", bot_running=bot_status(), theme=session['theme']) + return redirect(url_for("login")) @app.route("/users") def users(): - """Zeigt eine Liste aller Benutzer aus der Datenbank an.""" if "username" in session: + # Sicherstellen, dass das Theme gesetzt ist + if 'theme' not in session: + session['theme'] = 'light' + connection = get_db_connection() cursor = connection.cursor(dictionary=True) cursor.execute("SELECT * FROM user_data") users = cursor.fetchall() cursor.close() connection.close() - return render_template("users.html", users=users) + + return render_template("users.html", users=users, theme=session['theme']) return redirect(url_for("login")) if __name__ == "__main__":