Reputation: 11140
I have some urls that match:
(r'foo/[1-9]?[0-9]/?', Foo)
I am against having them be e.g. mydomain.tld/foo?n=84
only because I think it's a nice canonical(?) style to have permalinks without GET parameters.
I am currently doing:
class Handler(webapp2.RequestHandler):
#...
def currentURL(self):
return self.request.path_qs
class Foo(Handler):
def get(self):
n = re.match(r'.+/([1-9]?[0-9])/?', self.currentURL()).group(1)
#do something with n
But is there a cleaner, less hacky method?
Upvotes: 0
Views: 127
Reputation: 114068
from https://webapp-improved.appspot.com/guide/routing.html ... I think the following will work
(r'foo/([1-9]?[0-9])/?', Foo)
then
class Foo(Handler):
def get(self,n):
print n
Upvotes: 2