in my webapp2.RequestHandler method:
I want to find out which uri the requester want to get.
for example, if the user wants to get “http://www.mysite.com/products/table”
I want to get into a variable the value “table” (in this case)
when I print “self.request” I see all the values of RequestHandler class
but I didn’t managed to find out what is the right attribute in my case.
I’m sure the question is an easy-one for you, but I’m just a starter in python and app-engine framework.
Looked into how URLs should be handled, and wildcard URLs. Try this:
When I go to the URL
http://localhost:8080/products/table, I get this result:The
resourceparameter of thegetfunction is passed in automatically by theWSGIApplicationurl_mapping, because it is mapped to:The
(.*)is a wildcard, and gets passed in as a method parameter.You could name the parameter in the
getmethod anything you want instead ofresource, such astable. It wouldn’t make a lot of sense though, because if you pass in a url likehttp://localhost:8080/products/fish, it would no longer contain the word “table”.Earlier attempt (before edits):
Try something like this:
For my test, I went to
http://localhost:8080/, and it printed out:See the docs for the
Requestclass here.