add: whitelist
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user