Clinteney Hui
Clinteney Hui

Reputation: 4565

Why cant map the url to my request handler

('/\d+\?fmt=json',JsonHandler)

class JsonHandler(webapp.RequestHandler):
def get(self):
    self.response.out.write("hello")

Hey, I am using google app engine python and tring to map the url to my request handler. The url is digits followed by ?fmt=json, but it just doesnt print out "hello" and the regex test returns true, say 1234?fmt=json. any help? thank you

Upvotes: 0

Views: 254

Answers (1)

Calvin
Calvin

Reputation: 4195

You shouldn't include the query parameter in the regex.

('/\d+',JsonHandler)

class JsonHandler(webapp.RequestHandler): 
  def get(self):
    if self.request.get("fmt") == "json": #check the query string in the get handler
      self.response.out.write("hello")

Upvotes: 2

Related Questions