new api feuture

This commit is contained in:
2000-Trek 2023-07-05 22:41:40 +02:00
parent 8cac75d8d5
commit a66b883995
2 changed files with 16 additions and 1 deletions

View file

@ -285,7 +285,9 @@ def api_change():
if change == None:
change = 1
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user[0]}")
db_log.info(f"Changed the balance from user {user[0]} from {balance_old} to {user[2]}")
c.execute(f"SELECT * FROM users WHERE id = {userid}")
user_new = c.fetchall()[0]
db_log.info(f"Changed the balance from user {user[0]} from {user[2]} to {user_new[2]}")
socketio.emit("update", "update")
return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user[2]}))

View file

@ -12,6 +12,19 @@
</div>
<h1 class="header"> <u>Documentation</u> </h1>
<p>http://matekasse.server.c3h/api/tag_id?={tag_id}</p>
<p>Response:
{"mode":"error" "error":"{error}"}
{"mode":"message","username":"{username}","message":"{message}"}
{"mode":"balance", "username":"{username}", "balance":"{balance}"}
</p>
<br></br>
<p>http://matekasse.server.c3h/api/change?id={user_id}?change={change}</p>
<p>
If change = None the change will be 1
Response:
{"mode":"error" "error":"{error}"}
{"mode":"balance", "username":"{username}", "balance":"{balance}"}
</p>
<p>&nbsp;</p>
<div id="text">
<h2>API:</h2>