diff --git a/app.py b/app.py index 918c006..25ad33c 100644 --- a/app.py +++ b/app.py @@ -96,7 +96,10 @@ def chat(room_name): username = request.args.get("username", "guest") # Pass username and rooms into the template - return render_template("chat.html", room_name=room_name, rooms=rooms, username=username) + return render_template( + "chat.html", room_name=room_name, rooms=rooms, username=username + ) + @socketio.on("join") def on_join(data): @@ -113,7 +116,6 @@ def on_join(data): # Fetch previous messages from the database previous_messages = Message.query.filter_by(room_id=room.id).all() - # Send the history of messages only to the newly connected client. # The reason for using `request.sid` here is to target the specific session (or client) that # just connected, so only they receive the backlog of messages, rather than broadcasting