Kategorie Log aufgewertet
This commit is contained in:
parent
fddc4defbd
commit
0f55bc9cee
3 changed files with 85 additions and 1 deletions
38
app.py
38
app.py
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -394,4 +394,37 @@ text-decoration: underline;
|
|||
|
||||
width: 100% !important;
|
||||
height: 450px !important;
|
||||
}
|
||||
|
||||
|
||||
.log-actions a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.log-actions button {
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
|
||||
.log-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.log-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.log-actions a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.log-actions button {
|
||||
min-width: 120px;
|
||||
}
|
||||
|
|
@ -50,7 +50,22 @@
|
|||
<a href="/log">Log</a>
|
||||
|
||||
</div>
|
||||
<div class="log-actions">
|
||||
|
||||
<a href="/log/download">
|
||||
<button type="button">
|
||||
Download
|
||||
</button>
|
||||
</a>
|
||||
|
||||
<a href="/log/delete"
|
||||
onclick="return confirm('Logdatei löschen und Backup anlegen?');">
|
||||
<button type="button">
|
||||
Löschen
|
||||
</button>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div class="container">
|
||||
|
||||
<div class="card">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue