Created
September 9, 2018 14:39
-
-
Save chiragchamoli/cfcb53a49a790c70cd56ecf2f1c9d76b 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