静态文件

静态文件是指我们服务器上的图片、JavaScript、css,等资源,bottle 提供了 static_file 方法可以轻松定义一个静态文件服务器。


访问静态资源

@route('/static/<filename:path>')
def server_static(filename):
    return static_file(filename, root='./path/to/your/static/files')

强制下载

@route('/download/<filename:path>')
def download(filename):
    return static_file(filename, root='./path/to/static/files', download=filename)
CATEGORIES