如何通过瓶子默认提供 index.html?
How to serve index.html by default via bottle?
我有一个静态文件的路由定义为
@bottle.route('/status/<filename>')
def server_static(filename):
root = os.path.join(os.path.dirname(__file__), 'status', 'public_html')
return bottle.static_file(filename, root=root)
当我调用 http://localhost/status/index.html
(或任何其他文件)时它工作正常。
有没有办法在调用http://localhost/status
时默认服务index.html
?相当于nginx中的DirectoryIndex
in Apache or index
添加/status
规则,将filename
的默认值设为index.html:
@bottle.route('/status')
@bottle.route('/status/<filename>')
def server_static(filename='index.html'):
root = os.path.join(os.path.dirname(__file__), 'status', 'public_html')
return bottle.static_file(filename, root=root)
我有一个静态文件的路由定义为
@bottle.route('/status/<filename>')
def server_static(filename):
root = os.path.join(os.path.dirname(__file__), 'status', 'public_html')
return bottle.static_file(filename, root=root)
当我调用 http://localhost/status/index.html
(或任何其他文件)时它工作正常。
有没有办法在调用http://localhost/status
时默认服务index.html
?相当于nginx中的DirectoryIndex
in Apache or index
添加/status
规则,将filename
的默认值设为index.html:
@bottle.route('/status')
@bottle.route('/status/<filename>')
def server_static(filename='index.html'):
root = os.path.join(os.path.dirname(__file__), 'status', 'public_html')
return bottle.static_file(filename, root=root)