from flask import stream_with_context, Response

@app.route('/stream_data')
def stream_data():

    def generate():
        for i in range(10000):
            yield str(i)
return Response(stream_with_context(generate()))
flask make_response with large files