6

I'm building a server using python and bottle.

How can I handle a request for a binary file?

I have read that I should use flask. There is a way for doing that without using flask?

1
  • Bottle and Flask are not servers they are web frameworks. Bottle and Flask both have some built in servers with them. What to do mean, send binary file? Do you want to send images and other files using Bottle and Bottles default server? Look up Static Files in Bottles Documents. Either way you do not need Flask.
    – i_4_got
    Commented Dec 6, 2012 at 2:43

1 Answer 1

11

Yes, you should use static_file function:

from bottle import static_file    

@route('/download/<filename:path>')
def download(filename):
    return static_file(filename, root='/path/to/static/files', download=filename)
1
  • so, in bottle, if we want to download something, we must save it at first????? i mean in Flask(werkzeug) we can just save the file it in to response.stream .
    – Sinux
    Commented Nov 4, 2015 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.