generator in flask

Found a way to yield values in flask. I wanted to send a large data, so this is useful. Here is a basic example.

from flask import Response

def test():
    def generate():'request started')
        for i in range(5):
            yield str(i)'request finished')
        yield ''
    return Response(generate(), mimetype='text/plain')

To understand generator, yield and streaming, go over following materials