You can try something like this:
import StringIO from flask import Flask, send_file, render_template def page_code(): strIO = StringIO.StringIO() strIO.write(render_template('hello.html', name='World')) strIO.seek(0) return send_file(strIO, attachment_filename="testing.txt", as_attachment=True)
It is not tested, but should give you an idea.
source share