forked from bton/matekasse
new api feuture
This commit is contained in:
parent
6e377f8708
commit
8cac75d8d5
2 changed files with 20 additions and 1 deletions
20
main.py
20
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
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
</div>
|
||||
<h1 class="header"> <u>Documentation</u> </h1>
|
||||
<p>http://matekasse.server.c3h/api/tag_id?={tag_id}</p>
|
||||
<p>response:</p>
|
||||
<p> </p>
|
||||
<div id="text">
|
||||
<h2>API:</h2>
|
||||
|
|
Loading…
Reference in a new issue