Python 将瓶子服务器路由到两个子文件夹?

Python 将瓶子服务器路由到两个子文件夹?,python,routing,bottle,Python,Routing,Bottle,两个子文件夹位于名为frontend的同一文件夹下 一个是app,另一个是dist 在main.py中,我喜欢跟随 @bottle.route('/') def server_static(filename="index.html"): return static_file(filename, root='./frontend/dist/') @bottle.route('/<filepath:path>') def server_static(filepath): re

两个子文件夹位于名为frontend的同一文件夹下

一个是app,另一个是dist

在main.py中,我喜欢跟随

@bottle.route('/') 
def server_static(filename="index.html"):
  return static_file(filename, root='./frontend/dist/')

@bottle.route('/<filepath:path>')
def server_static(filepath):
  return static_file(file path, root='./frontend/dist/')
现在,当用户访问主站点url(如www.example.com/)时,他们可以成功地从文件夹dist加载所有内容

但我想为文件夹应用程序添加一个特定的路由。这样,当用户访问www.example.com/dev/时,文件夹应用程序中的所有内容都将被加载

我试过了

@bottle.route('/dev') 
def server_static(filename="index.html"):
  return static_file(filename, root='./frontend/app/')

@bottle.route('/dev/<filepath:path>')
def server_static(filepath):
  return static_file(file path, root='./frontend/app/')
但这根本不起作用。我想这是因为我使用了filepath


任何人都可以就这种情况下的路线提供建议

当两个路由匹配时,将选择首先声明的路由。您需要首先声明最具体的路线:

@bottle.route('/') 
...

@bottle.route('/dev') 
...
@bottle.route('/dev/<filepath:path>')
...

# because this matches the previous two routes, it must come after them
@bottle.route('/<filepath:path>')
...

奇怪的是,我仍然得到如下错误信息2014-03-27 13:59:21853 server.py:593]default:get/dev HTTP/1.1 304-即使我遵循了顺序。有什么建议吗?304没问题。这意味着您的浏览器已经有了静态文件的副本