Complete the code to import the Flask-SocketIO class.
from flask_socketio import [1]
The SocketIO class is imported from flask_socketio to enable WebSocket support in Flask.
Complete the code to create a SocketIO instance with the Flask app.
socketio = [1](app)The SocketIO instance wraps the Flask app to enable WebSocket event handling.
Fix the error in the event handler decorator to listen for 'message' events.
@socketio.on('[1]') def handle_message(msg): print('Received:', msg)
The event name for receiving messages is 'message'. Using this decorator listens for incoming messages.
Fill both blanks to emit a 'response' event with data back to the client.
socketio.[1]('[2]', {'data': 'Hello client!'})
send instead of emit for custom events.Use emit to send a custom event named 'response' with data to the client.
Fill all three blanks to define a handler for client connection and send a welcome message.
@socketio.on('[1]') def [2](): socketio.[3]('welcome', {'msg': 'Welcome!'})
The @socketio.on('connect') decorator listens for client connections. The handler function handle_connect sends a 'welcome' event using emit.