Search code examples
routeswebapp2

webapp2 - route for hanlder with params


I have route defined in this way:

webapp2.Route(r'/v/<link:\d+>', handler=View),

Now I want to create another Route which will be for specific link. Something like:

webapp2.Route(r'/test', handler=View('specific link')),

Is there a way to create route in this way? Or should I create new handler and in this handler call another one with predefined link? If yes how can I achieve it?


Solution

  • There is a way to provide dictionary with defaults arguments to RequestHandler:

    webapp2.Route(r'/test', handler=View, defaults={'link': 'default_link'}),