2012-12-03 11 views

risposta

19

C'è uno snippet sul sito Web di Flask su una rotta "catch-all" per pallone. You can find it here.

Fondamentalmente il decoratore funziona concatenando due filtri URL. L'esempio della pagina è:

@app.route('/', defaults={'path': ''}) 
@app.route('/<path:path>') 
def catch_all(path): 
    return 'You want path: %s' % path 

che darebbe:

% 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 
Problemi correlati