Created
May 22, 2018 15:09
-
-
Save meganlkm/6e150f0074c193f3bbbd850c5e42bd03 to your computer and use it in GitHub Desktop.
download a rendered template as a StringIO object in a Flask app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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