二进制文件下载

Vic*_*tor 6 python web-services bottle

我正在使用python和bottle构建服务器.

如何处理二进制文件的请求?

我读过我应该用烧瓶.有没有办法在不使用烧瓶的情况下做到这一点?

drn*_*gis 10

是的,你应该使用static_file功能:

from bottle import static_file    

@route('/download/<filename:path>')
def download(filename):
    return static_file(filename, root='/path/to/static/files', download=filename)
Run Code Online (Sandbox Code Playgroud)