forked from bton/matekasse
Error Codes
This commit is contained in:
parent
d9b0fe5dde
commit
a5102a9cd7
1 changed files with 15 additions and 3 deletions
18
main.py
18
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)
|
||||
|
|
Loading…
Reference in a new issue