Closed pythononwheels closed 6 years ago
added to v.8.2. werkzeug routes work directly. also added an example to handlers/shorties.py
@app.add_route('/werkzeug/<int:year>', dispatch={"get" : "test"})
@app.add_route('/werkzeug/<uuid:identifier>', dispatch={"get" : "testuuid"})
@app.add_route('/werkzeug/<uuid:identifier>.<format>', dispatch={"get" : "testuuid"})
class WerkzeugTestHandler(BaseHandler):
# on HTTP GET this method will be called. See dispatch parameter.
def test(self, year=None):
self.write("I got year: " + str(year))
def testuuid(self, anotherone=None, identifier=None, format="html"):
self.write("I got uuid: " + str(identifier)
+ "<hr> I got anotherone ? == " + str(anotherone)
)
make the app.add_route decorator accept werkzeug style routes as well. Scope: This will only affect the regex. Usage stays the same.
app.add_route( route_regex, dispatch={} )
Current usage:-->regex groups will be handed over to the handler mathod as parameters
New Option: will include Werkzeug routres as well
@app.add_route("/thanks/<int:year>", dispatch={"get": "testme"})
=>Rule("/thanks/<int:year>", endpoint="testme")
@app.add_route("/thanks/<int:year>/<int:month>/<int:day>/<slug>", dispatch={"get": "testme"})
=>Rule('/thanks<int:year>/<int:month>/<int:day>/<slug>', endpoint="testme")
The compiled Rule will be added to the tornado routes with the accordiung dispathc dict. See
application.add_route()
see: http://werkzeug.pocoo.org/docs/0.14/routing/