使文件可在工作/项目目录外下载

2024-09-26 22:49:38 发布

您现在位置:Python中文网/ 问答频道 /正文

当文件位于文件系统根目录中时,如何使文件可供下载。例如,在ubuntu操作系统的“media”目录中?你知道吗

Python:

#bottle 0.12.10
@route('/download/<filename:path>')
def staticdownloadfile(filename):
    return bottle.static_file(filename, root='/media', download=filename)

html格式:

<a href="/static/media/somefile.extension">download here</a>

上述方法不起作用?找不到404。你知道吗


Tags: 文件path目录bottlereturnubuntudownloaddef

热门问题