teardown_request

Python: Using Flask to stream chunked dynamic content to end users

If you are using Flask to generate dynamic content of significant size, such as large binary images/pdf or large text-based datasets, then you need to consider streaming to minimize the memory footprint of Flask and preserve scalability. Using an inner generate function and a yield allows Flask to return chunks of data back to the Python: Using Flask to stream chunked dynamic content to end users