forked from bton/matekasse
new api feuture
This commit is contained in:
parent
8cac75d8d5
commit
a66b883995
2 changed files with 16 additions and 1 deletions
4
main.py
4
main.py
|
@ -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]}))
|
||||
|
||||
|
|
|
@ -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> </p>
|
||||
<div id="text">
|
||||
<h2>API:</h2>
|
||||
|
|
Loading…
Reference in a new issue