From be29750c85a9b35739d08b2d47f44651a34afd20 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Fri, 16 Jun 2023 19:29:49 +0200 Subject: [PATCH] Don't show a message after change --- main.py | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index d0a8f22..b7d3880 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ import queue from flask import Flask, render_template, request, make_response, session -from flask_socketio import SocketIO, join_room, leave_room #https://pythonprogramminglanguage.com/python-flask-websocket/ +from flask_socketio import SocketIO, join_room, leave_room from flask_session import Session import sqlite3 import time @@ -107,6 +107,7 @@ def remove_user(): c.execute(f"DELETE FROM tags WHERE userid={user_id}") c.execute(f"DELETE FROM users WHERE id={user_id}") conn.commit() + socketio.emit("update", "update") return f'

Deleted user {user_name}

return to the tags and user list' @app.route("/adduser/user", methods=['GET']) @@ -116,6 +117,7 @@ def adduser(): if c.fetchall() == []: c.execute("INSERT or IGNORE INTO users (username, balance) VALUES (?, 0)", [user]) conn.commit() + socketio.emit("update", "update") return 'Added user user and tag list

The creator of this website accepts no liability for any linguistic or technical errors!

' else: return '

User already exists

user and tag list' @@ -129,18 +131,27 @@ def change(): except ValueError: return '

Please enter a number!

tags and user list' c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}") - 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 "

Nothing was done!

" - c.execute(f"SELECT * FROM users WHERE id={user_id}") - user = c.fetchall()[0][1] - return f'

{change_text} was {text} {user}

back to the list' + socketio.emit("update", "update") + return """ + + + + """ + #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 "

Nothing was done!

" + #c.execute(f"SELECT * FROM users WHERE id={user_id}") + #user = c.fetchall()[0][1] + #return f'

{change_text} was {text} {user}

back to the list' @app.route("/addtag", methods=['GET']) def get_addtag_request(): @@ -274,4 +285,4 @@ def get_id(): def main(): atexit.register(exit_handler) - socketio.run(app, host='0.0.0.0', port=5000) + socketio.run(app, host='0.0.0.0', port=5000) \ No newline at end of file