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)



The RequestHandler Class

The RequestHandler class is the superclass for an HTTP request handler.

RequestHandler is provided by the google.appengine.ext.webapp module.

  1. Introduction
  2. RequestHandler()
  3. Instance methods:
  4. Instance attributes:

Introduction

A webapp application defines one or more RequestHandler classes to handle requests. A handler class overrides one or more of the following methods to handle HTTP requests of the corresponding kind: get() , post() , head() , options() , put() , delete() , or trace() .

Constructor

class RequestHandler ()

The base class for an HTTP request handler.

The constructor takes no arguments. The instance can be initialized with the initialize() method.

Instance Methods

Subclasses of the RequestHandler class inherit or override the following methods:

get (* args )
Called to handle an HTTP GET request. Overridden by handler subclasses.
post (* args )
Called to handle an HTTP POST request. Overridden by handler subclasses.
put (* args )
Called to handle an HTTP PUT request. Overridden by handler subclasses.
head (* args )
Called to handle an HTTP HEAD request. Overridden by handler subclasses.
options (* args )
Called to handle an HTTP OPTIONS request. Overridden by handler subclasses.
delete (* args )
Called to handle an HTTP DELETE request. Overridden by handler subclasses.
trace (* args )
Called to handle an HTTP TRACE request. Overridden by handler subclasses.
handle_exception ( exception , debug_mode )
Called when an exception is raised by a handler. By default, handle_exception sets an HTTP status code of 500 ("Server error"). If debug_mode is True it prints a stack trace to the browser. Otherwise it just prints a plain error message. A RequestHandler class can override this method to provide custom behavior.
error ( code )
A shortcut method for handlers to use to return an error response. Clears the response output stream and sets the HTTP error code to code . Equivalent to calling self.response.clear() and self.response.set_status(code) .
redirect ( uri , permanent = False )
A shortcut method for handlers to use to return a redirect response. Sets the HTTP error code and Location: header to redirect to uri , and clears the response output stream. If permanent is True , it uses the HTTP status code 301 for a permanent redirect. Otherwise, it uses the HTTP status code 302 for a temporary redirect.
initialize ( request , response )
Initializes the handler instance with Request and Response objects. Typically, the WSGIApplication does this after instantiating the handler class.

Instance Attributes

An instance of a subclass of RequestHandler has the following attributes:

request
A Request instance. Typically, this attribute is initialized by the WSGIApplication after the object is constructed.
response
A Response instance. Typically, this attribute is initialized by the WSGIApplication after the object is constructed.

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.