Kategorie Log aufgewertet

This commit is contained in:
hubobel 2026-06-24 17:28:22 +02:00
parent fddc4defbd
commit 0f55bc9cee
3 changed files with 85 additions and 1 deletions

38
app.py
View file

@ -3,7 +3,7 @@ from flask import Flask, render_template, request
import subprocess
import sys
import json
from flask import redirect
from flask import redirect, send_file
from urllib.request import urlopen
from pathlib import Path
from influxdb_client import InfluxDBClient
@ -11,6 +11,7 @@ from datetime import datetime, timedelta
from collections import defaultdict
from datetime import datetime
import shutil
from shutil import copy2
import logging
import platform
# --------------------------------------------------
@ -412,6 +413,41 @@ def test_influx():
"last": data[-1] if data else None
}
@app.route("/log/download")
def download_log():
return send_file(
log_file,
as_attachment=True,
download_name="ing.log"
)
@app.route("/log/delete")
def delete_log():
if log_file.exists():
backup_file = (
log_file.parent
/ "ing.log.bak"
)
copy2(
log_file,
backup_file
)
with open(
log_file,
"w",
encoding="utf-8"
) as f:
f.write(
f"{datetime.now()} "
"[INFO] Logdatei gelöscht, Backup erstellt.\n"
)
return redirect("/log")
@app.route("/run/balance", methods=["POST"])
def run_balance():