2012-12-03 7 views

答えて

19

フラスコのキャッチオールルートについて、Flaskのウェブサイトにスニペットがあります。 You can find it here

デコレータは、基本的に2つの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 
関連する問題