human
Solve the following python programming problem given the following code:
@app.route('/stream/<int:n>')
def stream_n_messages(n):
assistant
#Here is the Python program you requested.

    """Stream n JSON messages
    """
    response = get_dict('url', 'args', 'headers', 'origin')
    n = min(n, 100)
    def generate_stream():
        for i in range(n):
            response['id'] = i
            (yield (json.dumps(response) + '\n'))
    return Response(generate_stream(), headers={'Content-Type': 'application/json'})