modified: app.py
This commit is contained in:
26
app.py
26
app.py
@@ -90,6 +90,32 @@ def make_discord_session(token=None, state=None):
|
|||||||
token_updater=token_updater
|
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():
|
def is_bot_admin():
|
||||||
"""Überprüft, ob der Benutzer globale Admin-Rechte hat."""
|
"""Überprüft, ob der Benutzer globale Admin-Rechte hat."""
|
||||||
|
|||||||
Reference in New Issue
Block a user