11
bunu yapmak mümkündür: Bir şişe eşdeğerPython - Flask Varsayılan Rota mümkün mü? Cherrypy
@cherrypy.expose
def default(self, url, *suburl, **kwarg):
pass
var mı?
bunu yapmak mümkündür: Bir şişe eşdeğerPython - Flask Varsayılan Rota mümkün mü? Cherrypy
@cherrypy.expose
def default(self, url, *suburl, **kwarg):
pass
var mı?
Flask'in web sitesinde, şişe için 'tümünü yakala' rotası hakkında bir snippet var. You can find it here.
Temel olarak, dekoratör iki URL filtresini zincirleyerek çalışır. sayfadaki örnektir:
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
return 'You want path: %s' % path
size verecek Hangi:
% 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