Skip to content

Instantly share code, notes, and snippets.

@meganlkm

meganlkm/app.py

Created May 22, 2018
Embed
What would you like to do?
download a rendered template as a StringIO object in a Flask app
from StringIO import StringIO
from flask import Flask, render_template, send_file
app = Flask(__name__)
@app.route('/bootstrap')
def bootstrap():
str_io = StringIO()
str_io.write(render_template('files/bootstrap.sh.j2'))
str_io.seek(0)
return send_file(
str_io,
attachment_filename='bootstrap.sh',
as_attachment=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.