From e29414b352c0bace370f0a58b689746fc71f7a4c Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:07:50 +0100 Subject: [PATCH] modified: app.py --- app.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app.py b/app.py index 77ae2b4..bd18f46 100644 --- a/app.py +++ b/app.py @@ -90,6 +90,32 @@ def make_discord_session(token=None, state=None): token_updater=token_updater ) +@app.route("/logs") +def view_logs(): + """Zeigt die Logs des Bots im Admin-Panel an.""" + if is_bot_admin(): + return render_template("logs.html") + return redirect(url_for("landing_page")) + +@app.route("/get_logs") +def get_logs(): + """Liest den Inhalt der Log-Datei und gibt ihn zurück.""" + if is_bot_admin(): + try: + with open(LOG_FILE_PATH, 'r', encoding='utf-8') as file: + logs = file.read() + return jsonify({"logs": logs}) + except FileNotFoundError: + return jsonify({"logs": "Log file not found."}) + return redirect(url_for("landing_page")) + +@app.route("/download_logs") +def download_logs(): + """Bietet die Log-Datei zum Download an.""" + if is_bot_admin(): + return send_file(LOG_FILE_PATH, as_attachment=True) + return redirect(url_for("landing_page")) + def is_bot_admin(): """Überprüft, ob der Benutzer globale Admin-Rechte hat."""