11
In CherryPy è possibile fare questo:Python - Flask Percorso predefinito possibile?
@cherrypy.expose
def default(self, url, *suburl, **kwarg):
pass
C'è un pallone equivalente?
In CherryPy è possibile fare questo:Python - Flask Percorso predefinito possibile?
@cherrypy.expose
def default(self, url, *suburl, **kwarg):
pass
C'è un pallone equivalente?
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