Created
June 3, 2015 11:01
-
-
Save jacob414/f4ab2415229321d0973b to your computer and use it in GitHub Desktop.
Flask streaming + path.py quickie
This file contains hidden or 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 path import path | |
import mimetypes | |
from flask import stream_with_context, Response | |
@app.route('/download/<id>') | |
def download(id): | |
# fp_as_string = my_source.get_a_file(id) | |
guessed, _ = mimetypes.guess_type(fp_as_string) | |
return Response(stream_with_context( | |
path(fp_as_string).chunks(2048, mode='rb')), mimetype=guessed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment