1
0
Fork 0
forked from bton/matekasse

Added cheks to make shure there is no SQLite error

This commit is contained in:
2000-Trek 2023-06-21 23:00:22 +02:00
parent 05a5519a59
commit 74850ed77b

20
main.py
View file

@ -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>'
else:
return "Error: 043"
@app.route("/adduser/user", methods=['GET'])
def adduser():
user = request.args.get("username")
@ -132,11 +133,13 @@ def adduser():
@app.route("/change", methods=['GET'])
def change():
user_id = int(request.args.get("id"))
try:
user_id = int(request.args.get("id"))
change = int(request.args.get("change"))
except ValueError:
return '<p>Error: 095</p><a href="/list">tags and user list</a>'
c.execute(f"SELCET * FROM users WHERE id={user_id}")
if c.fetchall != []:
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
socketio.emit("update", "update")
return """<html>
@ -146,19 +149,8 @@ def change():
</script>
</html>
"""
#socketio.emit("update", "update")
#conn.commit()
#if change < 0:
# text = "removed from"
# 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>'
else:
return "Error: 043"
@app.route("/addtag", methods=['GET'])
def get_addtag_request():