srv/poe_manager/app.py aktualisiert
This commit is contained in:
@@ -122,12 +122,23 @@ def settings():
|
||||
|
||||
if request.method == "POST":
|
||||
new_interval = int(request.form["interval"])
|
||||
|
||||
# Minuten und Sekunden berechnen
|
||||
interval_minutes = new_interval
|
||||
check_interval_seconds = new_interval * 60
|
||||
|
||||
conn = sqlite3.connect("sqlite.db")
|
||||
c = conn.cursor()
|
||||
# upsert
|
||||
c.execute("INSERT INTO settings (key, value) VALUES (?, ?) "
|
||||
"ON CONFLICT(key) DO UPDATE SET value=excluded.value",
|
||||
("interval", new_interval))
|
||||
# interval (Minuten)
|
||||
c.execute("""
|
||||
INSERT INTO settings (key, value) VALUES (?, ?)
|
||||
ON CONFLICT(key) DO UPDATE SET value=excluded.value
|
||||
""", ("interval", interval_minutes))
|
||||
# check_interval (Sekunden)
|
||||
c.execute("""
|
||||
INSERT INTO settings (key, value) VALUES (?, ?)
|
||||
ON CONFLICT(key) DO UPDATE SET value=excluded.value
|
||||
""", ("check_interval", check_interval_seconds))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -135,7 +146,7 @@ def settings():
|
||||
import subprocess
|
||||
subprocess.run(["systemctl", "restart", "rpi-check.service"])
|
||||
|
||||
flash(f"Intervall auf {new_interval} Minuten gesetzt und Service neu gestartet!")
|
||||
flash(f"Intervall auf {interval_minutes} Minuten gesetzt und Service neu gestartet!")
|
||||
return redirect(url_for("settings"))
|
||||
|
||||
return render_template("settings.html", interval=interval)
|
||||
|
||||
Reference in New Issue
Block a user