diff --git a/main.py b/main.py index 364c707..5167ddf 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +from crypt import methods from fileinput import filename import queue, sqlite3, time, atexit, sys, uuid, json, urllib.parse, logging, datetime, os from flask import Flask, render_template, request, make_response, session, url_for @@ -270,6 +271,25 @@ def request_removetag(data): leave_room(session[id]) #api +@app.route("/api/change", methods=['GET']) +def api_change(): + userid = request.args.get("id") + c.execute("SELECT * FROM users WHERE id=?", [userid]) + user_list = c.fetchall() + if user_list != []: + user = user_list[0] + try: + change = int(request.args.get("change")) + except: + return make_response(json.dumps({"mode":"error","error":"095"})) + 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]}") + socketio.emit("update", "update") + return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user[2]})) + + @app.route("/api/tag_id", methods=['GET']) def get_id(): global finished diff --git a/templates/documentation.html b/templates/documentation.html index da4fa2b..576ead3 100644 --- a/templates/documentation.html +++ b/templates/documentation.html @@ -12,7 +12,6 @@
http://matekasse.server.c3h/api/tag_id?={tag_id}
-response: