API return json
This commit is contained in:
parent
be29750c85
commit
6b21837789
1 changed files with 4 additions and 1 deletions
5
main.py
5
main.py
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue