This commit is contained in:
2026-03-02 09:28:37 +00:00
parent 3835ae16b3
commit 19b72a8f5c
+9 -3
View File
@@ -7,7 +7,7 @@ app = Flask(__name__)
pattern = re.compile(r"^(?:[01]\d|2[0-3]):[0-5]\d$") # Regex "XX:XX"
DB_PATH = "data.db"
DEFAULT_TIME = "21:00"
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
@@ -44,7 +44,7 @@ def mainpage():
items = cursor.fetchall()
cursor.execute("SELECT default_time FROM val")
default_time_row = cursor.fetchone()
default_time = default_time_row[0] if default_time_row else '21:00'
default_time = default_time_row[0] if default_time_row else DEFAULT_TIME
conn.close()
return render_template('index.html', title='BS Shutdown', items=items, default_time=default_time)
@@ -117,9 +117,15 @@ def lookup():
(name,)
)
item = cursor.fetchone()
cursor.execute(
"SELECT default_time FROM val",
(name,)
)
default_time_row = cursor.fetchone()
default_time = default_time_row[0] if default_time_row else DEFAULT_TIME
conn.close()
if item:
return jsonify({"name": item["name"], "noshutdown": item["noshutdown"], "time": item["time"]}), 200
else:
return jsonify({"error": "Not found"}), 404
return jsonify({"noshutdown": 0, "time": default_time}), 200