本文介绍了二进制文件下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用python和bottle构建服务器.
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?
推荐答案
是的,您应该使用static_file
函数:
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)
这篇关于二进制文件下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!