Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Request Handlers

When a WSGIApplication receives a request, it creates an instance of the RequestHandler class associated with the URL path in the request. It then calls a method that corresponds with the HTTP action of the request, such as the get() method for a HTTP GET request. The method processes the request and prepares a response, then returns. Finally, the application sends the response to the client.

The following example defines a request handler that responds to HTTP GET requests:

class AddTwoNumbers(webapp.RequestHandler):

    def get(self):
        try:
            first = int(self.request.get('first'))
            second = int(self.request.get('second'))

            self.response.out.write("<html><body><p>%d + %d = %d</p></body></html>" %
                                    (first, second, first + second))
        except (TypeError, ValueError):
            self.response.out.write("<html><body><p>Invalid inputs</p></body></html>")

A request handler can define any of the following methods to handle the corresponding HTTP actions:

  • get()
  • post()
  • head()
  • options()
  • put()
  • delete()
  • trace()

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.