@route('/download/') def download_file(hash): pass
比如写成这种restful形式, 当用户访问带hash的连接的时候下载对应文件, 服务器的response该怎么写?
@route('/download/<filename:path>') def download(filename): return static_file(filename, root='/path/to/static/files', download=filename)
文档中不是有示例了么?打开 http://bottlepy.org/docs/dev/tutorial.html#generating-content 搜 Force Download.
除了static_file之外,还可以直接return 字符串就行,如果要具体设置content-type之类的,可以修改bottle.response的相关属性