From a12366867d99629cd9882abd45c666bc90014d29 Mon Sep 17 00:00:00 2001 From: Namonay Date: Fri, 20 Feb 2026 13:36:02 +0000 Subject: [PATCH] add: whitelist --- server/src/data/app.py | 14 +++++++++----- server/src/data/templates/base.html | 2 +- server/src/data/templates/index.html | 29 ++++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/server/src/data/app.py b/server/src/data/app.py index 5ed777a..a53b6a6 100644 --- a/server/src/data/app.py +++ b/server/src/data/app.py @@ -15,7 +15,10 @@ CREATE TABLE IF NOT EXISTS items ( time TEXT NOT NULL ) """) - +try: + cursor.execute("ALTER TABLE items ADD COLUMN noshutdown INTEGER DEFAULT 0") +except sqlite3.OperationalError: + pass conn.commit() conn.close() @@ -37,6 +40,7 @@ def mainpage(): def submit(): value = request.form.get("query") time_value = request.form.get("time") + noshutdown = request.form.get("noshutdown") if not value or not time_value: return redirect(url_for("mainpage")) conn = get_db_connection() @@ -47,8 +51,8 @@ def submit(): conn.close() return redirect(url_for("mainpage")) cursor.execute( - "INSERT INTO items (name, time) VALUES (?, ?)", - (value, time_value) + "INSERT INTO items (name, time, noshutdown) VALUES (?, ?)", + (value, time_value, noshutdown) ) conn.commit() conn.close() @@ -79,13 +83,13 @@ def lookup(): conn = get_db_connection() cursor = conn.cursor() cursor.execute( - "SELECT name, time FROM items WHERE name = ?", + "SELECT name, time, noshutdown FROM items WHERE name = ?", (name,) ) item = cursor.fetchone() conn.close() if item: - return jsonify({"name": item["name"], "time": item["time"]}), 200 + return jsonify({"name": item["name"], "noshutdown": item["noshutdown"], "time": item["time"]}), 200 else: return jsonify({"error": "Not found"}), 404 \ No newline at end of file diff --git a/server/src/data/templates/base.html b/server/src/data/templates/base.html index 6e1748f..9fd797c 100644 --- a/server/src/data/templates/base.html +++ b/server/src/data/templates/base.html @@ -35,7 +35,7 @@