Complete the code to import the Flask class.
from flask import [1] app = [1](__name__)
The Flask class is imported to create the app instance.
Complete the code to define a route that returns 'Hello World!'.
@app.route('/') def home(): return [1]
The route function returns a simple string 'Hello World!'.
Fix the error in the code to run the Flask app.
if __name__ == '__main__': app.[1](debug=True)
The Flask app is started using the run() method.
Fill both blanks to create a real-time message update using Flask-SocketIO.
from flask_socketio import SocketIO socketio = SocketIO(app) @socketio.[1]('[2]') def handle_message(msg): print('Message:', msg)
The decorator @socketio.on('send') listens for 'send' events.
Flask-SocketIO uses 'on' to register event handlers.
Fill all three blanks to emit a real-time event to clients.
from flask_socketio import emit @app.route('/notify') def notify(): [1]('notification', [2]={'msg': 'Update!'}, [3]=True) return 'Notified'
The emit function sends an event named 'notification'.
The data argument is a dictionary with the message.
The broadcast=True option sends to all connected clients.
