modified: app.py

This commit is contained in:
SimolZimol
2024-09-03 11:24:57 +02:00
parent ea568ace32
commit 2fc24afcb9

22
app.py
View File

@@ -68,12 +68,6 @@ def get_db_connection():
database=DB_NAME 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"]) @app.route("/login", methods=["GET", "POST"])
def login(): def login():
if request.method == "POST": 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 render_template("settings.html", introduction=introduction, asknotes_introduction=asknotes_introduction, theme=session.get('theme', 'light'))
return redirect(url_for("login")) 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") @app.route("/users")
def users(): def users():
"""Zeigt eine Liste aller Benutzer aus der Datenbank an."""
if "username" in session: if "username" in session:
# Sicherstellen, dass das Theme gesetzt ist
if 'theme' not in session:
session['theme'] = 'light'
connection = get_db_connection() connection = get_db_connection()
cursor = connection.cursor(dictionary=True) cursor = connection.cursor(dictionary=True)
cursor.execute("SELECT * FROM user_data") cursor.execute("SELECT * FROM user_data")
users = cursor.fetchall() users = cursor.fetchall()
cursor.close() cursor.close()
connection.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")) return redirect(url_for("login"))
if __name__ == "__main__": if __name__ == "__main__":