forked from bton/matekasse
Added cheks to make shure there is no SQLite error
This commit is contained in:
parent
05a5519a59
commit
74850ed77b
1 changed files with 16 additions and 24 deletions
40
main.py
40
main.py
|
@ -117,6 +117,7 @@ def remove_user():
|
||||||
return f'<p>Deleted user {user_name}</p><a href="/list">return to the tags and user list</a>'
|
return f'<p>Deleted user {user_name}</p><a href="/list">return to the tags and user list</a>'
|
||||||
else:
|
else:
|
||||||
return "Error: 043"
|
return "Error: 043"
|
||||||
|
|
||||||
@app.route("/adduser/user", methods=['GET'])
|
@app.route("/adduser/user", methods=['GET'])
|
||||||
def adduser():
|
def adduser():
|
||||||
user = request.args.get("username")
|
user = request.args.get("username")
|
||||||
|
@ -132,34 +133,25 @@ def adduser():
|
||||||
|
|
||||||
@app.route("/change", methods=['GET'])
|
@app.route("/change", methods=['GET'])
|
||||||
def change():
|
def change():
|
||||||
user_id = int(request.args.get("id"))
|
|
||||||
try:
|
try:
|
||||||
|
user_id = int(request.args.get("id"))
|
||||||
change = int(request.args.get("change"))
|
change = int(request.args.get("change"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return '<p>Error: 095</p><a href="/list">tags and user list</a>'
|
return '<p>Error: 095</p><a href="/list">tags and user list</a>'
|
||||||
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
|
c.execute(f"SELCET * FROM users WHERE id={user_id}")
|
||||||
socketio.emit("update", "update")
|
if c.fetchall != []:
|
||||||
return """<html>
|
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
|
socketio.emit("update", "update")
|
||||||
<script type="text/javascript" charset="utf-8">
|
return """<html>
|
||||||
window.location="http://matekasse.server.c3h/list";
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
|
||||||
</script>
|
<script type="text/javascript" charset="utf-8">
|
||||||
</html>
|
window.location="http://matekasse.server.c3h/list";
|
||||||
"""
|
</script>
|
||||||
#socketio.emit("update", "update")
|
</html>
|
||||||
#conn.commit()
|
"""
|
||||||
#if change < 0:
|
else:
|
||||||
# text = "removed from"
|
return "Error: 043"
|
||||||
# change_text = change * -1
|
|
||||||
#elif change > 0:
|
|
||||||
# text = "added to"
|
|
||||||
# change_text = change
|
|
||||||
#elif change == 0:
|
|
||||||
# return "<p>Nothing was done!</p>"
|
|
||||||
#c.execute(f"SELECT * FROM users WHERE id={user_id}")
|
|
||||||
#user = c.fetchall()[0][1]
|
|
||||||
#return f'<p>{change_text} was {text} {user}</p> <a href="/list">back to the list</a>'
|
|
||||||
|
|
||||||
@app.route("/addtag", methods=['GET'])
|
@app.route("/addtag", methods=['GET'])
|
||||||
def get_addtag_request():
|
def get_addtag_request():
|
||||||
global users
|
global users
|
||||||
|
|
Loading…
Reference in a new issue