You cannot return multiple responses to a single request. Instead, create and save files somewhere, and serve them using a different route. Return the processed template with the URL for the route that the file will serve.
@app.route('/database') def database():
In the template, use url_for to create the download url.
<a href="{{ url_for('database_download', filename=filename) }}">Download</a>
source share