Complete the code to import the Flask class.
from flask import [1]
The Flask class is imported from the flask module to create the app.
Complete the code to create a Flask app instance.
app = [1](__name__)Creating the Flask app requires calling Flask with __name__.
Fix the error in the route decorator to define a streaming endpoint.
@app.route('/stream', [1]=['GET'])
The correct keyword argument to specify HTTP methods is 'methods'.
Fill both blanks to create a generator function that yields messages for streaming.
def event_stream(): while True: yield [1] + '\n\n' time.sleep([2])
The generator yields a string starting with 'data:' followed by two newlines, then sleeps 1 second.
Fill all three blanks to return a streaming response with correct mimetype.
from flask import Response @app.route('/stream') def stream(): return Response([1](), mimetype=[2]) # Use [3] mimetype for Server-Sent Events
The Response uses the event_stream generator and 'text/event-stream' mimetype for SSE.
