Reputation: 42828
I had gone through webapp2 Route to match all other paths
I try to
class SinkHandler(webapp2.RequestHandler):
def get(self, *args, **kwargs):
self.response.out.write('Sink')
application = webapp2.WSGIApplication([
(r'/<:.*>', SinkHandler)
], debug = True)
in order to match
http://localhost:9080/dummy
http://localhost:9080/dummy/eummy
http://localhost:9080/dummy/eummy/fummy
But it just yield 404 not found.
I can do it this way.
class SinkHandler(webapp2.RequestHandler):
def get(self, *args, **kwargs):
self.response.out.write('Sink')
application = webapp2.WSGIApplication([
(r'/(\w*)$', SinkHandler),
(r'/(\w*)/(\w*)$', SinkHandler),
(r'/(\w*)/(\w*)/(\w*)$', SinkHandler)
], debug = True)
It will able to match the above 3 type of URLs. However, if I need to support
http://localhost:9080/dummy/eummy/fummy/gummy
I need to add additional entry in WSGIApplication
Is there a smarter way, to match all other possible paths?
Upvotes: 0
Views: 91
Reputation: 16563
This should work:
application = webapp2.WSGIApplication([
(r'/.*', SinkHandler)
], debug = True)
To use the more general regexp, you need to use Route
:
from webapp2 import Route
application = webapp2.WSGIApplication([
Route(r'/<:.*>', SinkHandler)
], debug = True)
Upvotes: 1