From 6b218377895c8125f50fd0a8fd1b6504722b4d2e Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Wed, 21 Jun 2023 19:03:59 +0200 Subject: [PATCH] API return json --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index b7d3880..e36dd86 100644 --- a/main.py +++ b/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")