1
0
Fork 0
forked from bton/matekasse

new api feuture

This commit is contained in:
2000-Trek 2023-07-05 22:23:42 +02:00
parent 6e377f8708
commit 8cac75d8d5
2 changed files with 20 additions and 1 deletions

20
main.py
View file

@ -1,3 +1,4 @@
from crypt import methods
from fileinput import filename from fileinput import filename
import queue, sqlite3, time, atexit, sys, uuid, json, urllib.parse, logging, datetime, os 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 from flask import Flask, render_template, request, make_response, session, url_for
@ -270,6 +271,25 @@ def request_removetag(data):
leave_room(session[id]) leave_room(session[id])
#api #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']) @app.route("/api/tag_id", methods=['GET'])
def get_id(): def get_id():
global finished global finished

View file

@ -12,7 +12,6 @@
</div> </div>
<h1 class="header"> <u>Documentation</u> </h1> <h1 class="header"> <u>Documentation</u> </h1>
<p>http://matekasse.server.c3h/api/tag_id?={tag_id}</p> <p>http://matekasse.server.c3h/api/tag_id?={tag_id}</p>
<p>response:</p>
<p>&nbsp;</p> <p>&nbsp;</p>
<div id="text"> <div id="text">
<h2>API:</h2> <h2>API:</h2>