forked from bton/matekasse
ct
This commit is contained in:
parent
47999eff61
commit
6914a75f6c
1 changed files with 4 additions and 4 deletions
|
@ -306,11 +306,11 @@ def create_app(test_config=None):
|
||||||
leave_room(session[id])
|
leave_room(session[id])
|
||||||
|
|
||||||
#api
|
#api
|
||||||
@app.route("/api/change", methods=['GET'])
|
@app.route("/api/change", methods=['POST'])
|
||||||
def api_change():
|
def api_change():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
userid = request.args.get("id")
|
userid = request.form["id"]
|
||||||
c.execute("SELECT * FROM users WHERE id=?", [userid])
|
c.execute("SELECT * FROM users WHERE id=?", [userid])
|
||||||
user_list = c.fetchall()
|
user_list = c.fetchall()
|
||||||
if user_list != []:
|
if user_list != []:
|
||||||
|
@ -318,7 +318,7 @@ def create_app(test_config=None):
|
||||||
try:
|
try:
|
||||||
change = int(request.args.get("change"))
|
change = int(request.args.get("change"))
|
||||||
except:
|
except:
|
||||||
change = -1
|
change = -1.5
|
||||||
c.execute(f"UPDATE users SET balance = balance + {change*100} WHERE id={user[0]}")
|
c.execute(f"UPDATE users SET balance = balance + {change*100} WHERE id={user[0]}")
|
||||||
db.commit()
|
db.commit()
|
||||||
c.execute(f"SELECT * FROM users WHERE id = {userid}")
|
c.execute(f"SELECT * FROM users WHERE id = {userid}")
|
||||||
|
@ -393,7 +393,7 @@ def create_app(test_config=None):
|
||||||
user = c.fetchone()
|
user = c.fetchone()
|
||||||
log(type="balance", userid=user[0], before=balance_old, after=user[2])
|
log(type="balance", userid=user[0], before=balance_old, after=user[2])
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user[2]}))
|
return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user[2]/100}))
|
||||||
else:
|
else:
|
||||||
return make_response(json.dumps({"mode":"error", "error":"043"}))
|
return make_response(json.dumps({"mode":"error", "error":"043"}))
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
|
|
Loading…
Reference in a new issue