From a5102a9cd7fb5729d50fcabeb70a8f10a04a3ee3 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Wed, 21 Jun 2023 19:39:13 +0200 Subject: [PATCH] Error Codes --- main.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 64c8f93..f8594ac 100644 --- a/main.py +++ b/main.py @@ -258,17 +258,29 @@ def get_id(): c.execute(f"SELECT * FROM tags WHERE tagid={tag_id}") if c.fetchall() != []: message = "Tag already exists" + finished = queue_item + return make_response(json.dumps({"mode":"0","error":"170"})) else: c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})") message = tag_id + finished = queue_item + c.execute(f"SELECT * FROM users WHERE id={user}") + username = c.fetchall() + return make_response(json({"mode":"2","username":username,"code":"1"})) elif state == "remove": c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = {user})") tags = c.fetchall() if tags != []: c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ") message = tag_id + finished = queue_item + c.execute(f"SELECT * FROM users WHERE id={user}") + username = c.fetchall() + return make_response(json({"mode":"2","username":username,"code":"2"})) else: message = "Tag does not exist" + finished = queue_item + return make_response(json.dumps({"mode":"0","error":"054"})) conn.commit() finished = queue_item socketio.emit("update", "update") @@ -281,10 +293,10 @@ def get_id(): conn.commit() c.execute(f"SELECT * FROM users WHERE id={tag[1]}") user = c.fetchall()[0] - socketio.emit("update", "update") - return make_response(json.dumps({"username":user[1], "balance":user[2]})) + socketio.emit("update", "upfinished = queue_itemdate") + return make_response(json.dumps({"mode":"1", "username":user[1], "balance":user[2]})) socketio.emit("update", "update") - return make_response("False") + return make_response(json.dump({"mode":"0","error":"418"})) def main(): atexit.register(exit_handler)