diff --git a/app.py b/app.py index 09aecab..48ccc34 100644 --- a/app.py +++ b/app.py @@ -167,5 +167,26 @@ def download_logs(): return send_file(LOG_FILE_PATH, as_attachment=True) return redirect(url_for("login")) +import shutil + +ARCHIVE_DIR = "archive_logs" +if not os.path.exists(ARCHIVE_DIR): + os.makedirs(ARCHIVE_DIR) + +@app.route("/archive_logs", methods=["POST"]) +def archive_logs(): + """Archiviert die aktuelle Log-Datei und beginnt eine neue Log-Datei.""" + if "username" in session: + if os.path.exists(LOG_FILE_PATH): + timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') + archive_file = os.path.join(ARCHIVE_DIR, f"log_{timestamp}.log") + shutil.move(LOG_FILE_PATH, archive_file) + with open(LOG_FILE_PATH, 'w', encoding='utf-8') as file: + file.write("") # Neue leere Log-Datei starten + return jsonify({"status": "success", "message": "Logs archived successfully."}) + else: + return jsonify({"status": "error", "message": "Log file not found."}) + return redirect(url_for("login")) + if __name__ == "__main__": app.run(host="0.0.0.0", port=5000, debug=True) diff --git a/templates/logs.html b/templates/logs.html index 2710300..20fa00c 100644 --- a/templates/logs.html +++ b/templates/logs.html @@ -18,6 +18,19 @@ + + + +