2012-12-03 58 views

回答

19

在Flask的網站上有一個關於瓶子的「全包」途徑的片段。 You can find it here

基本上,裝飾者通過鏈接兩個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 rule 
You want path: 
% curl 127.0.0.1:5000/foo/bar # Matches the second rule 
You want path: foo/bar