In webapp2, I can instantiate an app like this...
routes = [('/products', 'ProductsHandler'),
('/', 'HomeHandler')]
app = webapp2.WSGIApplication(routes=routes)
None of the parameters are required. So, I figure I can instantiate like this...
app = webapp2.WSGIApplication()
app.routes = [('/products', 'ProductsHandler'),
('/', 'HomeHandler')]
However, the routes don't seem to be working this way. I'm getting 404 on both pages.
Is there something wrong with my syntax or is there something about WSGI that I don't understand?
webapp2 does some magic on routes (converting from the tuples to webapp2.Route
instances). When you just assign to routes, it won't work because they haven't been converted to the right format for webapp2. I believe you can just add in the Route instantiation and it should work.