Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary file download

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?

like image 824
Victor Avatar asked Dec 05 '12 14:12

Victor


1 Answers

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)
like image 113
drnextgis Avatar answered Sep 18 '22 23:09

drnextgis