I've the following code in my main app. I expect all paths other than the first two to be caught by the last route (/.*). But I get 404 error. What am I missing?
import webapp2
from webapp2 import WSGIApplication, Route
# ---- main handler
class MainPage(webapp2.RequestHandler):
def get(self):
ret = jinja2render.DoRender(self)
return ret
routes = [
Route (r'/rpc', handler = 'rpc.RPCHandler'),
Route (r'/secured/somesecuredpage', handler = 'secured.securedPageHandler'),
Route (r'/.*', handler = MainPage),
]
app = WSGIApplication(routes, debug=True)
I can change the last route from "/." to "/<:.>" to catch all other paths, but that also requires me to include a named parameter to MainPage.get function. Is that the only way to do or am I missing something? Thanks.
According to the URI template docs, this should do the trick:
Route (r'/<:.*>', handler=MainPage)
You may need to define your MainPage.get
method as follows to accept with the extra arguments:
def get(self, *args, **kwargs):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With