Created
July 14, 2018 09:11
-
-
Save chiragchamoli/451de8b8aa5cbf32739fe7f96323fc16 to your computer and use it in GitHub Desktop.
Upload a StringIO object with send_file
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
#!/usr/bin/env python | |
# Thanks to Dan Jacob for a part of the code ! | |
from flask import Flask, send_file | |
import StringIO | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
strIO = StringIO.StringIO() | |
strIO.write('Hello from Dan Jacob and Stephane Wirtel !') | |
strIO.seek(0) | |
return send_file(strIO, | |
attachment_filename="testing.txt", | |
as_attachment=True) | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment