balance get api
This commit is contained in:
parent
55124040ae
commit
d55b7c5aea
2 changed files with 35 additions and 22 deletions
|
@ -249,9 +249,9 @@ def create_app(test_config=None):
|
||||||
socketio.emit("error", "418", to=session[id])
|
socketio.emit("error", "418", to=session[id])
|
||||||
leave_room(session[id])
|
leave_room(session[id])
|
||||||
|
|
||||||
#api
|
@app.route("/api/balance", methods=['POST', 'GET'])
|
||||||
@app.route("/api/balance", methods=['POST'])
|
|
||||||
def api_change():
|
def api_change():
|
||||||
|
if request.method == 'POST':
|
||||||
db = get_db()
|
db = get_db()
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
userid = request.form["id"]
|
userid = request.form["id"]
|
||||||
|
@ -273,6 +273,18 @@ def create_app(test_config=None):
|
||||||
else:
|
else:
|
||||||
return make_response(json.dumps({"mode":"error","error":"043"}))
|
return make_response(json.dumps({"mode":"error","error":"043"}))
|
||||||
|
|
||||||
|
elif request.method == 'GET':
|
||||||
|
db = get_db()
|
||||||
|
c = db.cursor()
|
||||||
|
userid = reqest.args.get("id")
|
||||||
|
c.execute("SELECT * FROM users WHERE id=?", [userid])
|
||||||
|
user = c.fetchone()
|
||||||
|
if user != None:
|
||||||
|
return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user[2]}))
|
||||||
|
else:
|
||||||
|
return make_response(json.dumps({"mode":"error", "error":"043"}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/tag_id", methods=['POST'])
|
@app.route("/api/tag_id", methods=['POST'])
|
||||||
def get_id():
|
def get_id():
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<p>
|
<p>
|
||||||
If change = None or NaN the change will be -1
|
If change = None or NaN the change will be -1
|
||||||
</p>
|
</p>
|
||||||
|
<p>Get method ?id=user_id</p>
|
||||||
<p>
|
<p>
|
||||||
Response:
|
Response:
|
||||||
{"mode":"error" "error":"{error}"} or
|
{"mode":"error" "error":"{error}"} or
|
||||||
|
|
Loading…
Reference in a new issue