API return json

This commit is contained in:
2000-Trek 2023-06-21 19:03:59 +02:00
parent be29750c85
commit 6b21837789

View file

@ -7,6 +7,7 @@ import time
import atexit
import sys
import uuid
import json
db_path = 'mate.db'
conn = sqlite3.connect(db_path, check_same_thread=False)
@ -278,8 +279,10 @@ def get_id():
if users.qsize() == 0:
c.execute(f"UPDATE users SET balance = balance - 1 WHERE id={tag[1]}")
conn.commit()
c.execute(f"SELECT * FROM users WHERE id={tag[1]}")
user = c.fetchall()
socketio.emit("update", "update")
return make_response("True")
return make_response(json.dumps({"username":user[1], "balance":user[2]}))
socketio.emit("update", "update")
return make_response("False")