Flask网站上有一个片段,涉及烧瓶的“全包”路线。你可以在这里找到它。
基本上,装饰器通过链接两个URL过滤器来工作。页面上的示例是:
@app.route('/', defaults={'path': ''})@app.route('/<path:path>')def catch_all(path): return 'You want path: %s' % path这会给你:
% curl 127.0.0.1:5000 # Matches the first ruleYou want path: % curl 127.0.0.1:5000/foo/bar # Matches the second ruleYou want path: foo/bar



