Google App Engine

Building the Response

The request handler instance builds the response using its response property. This is initialized to an empty Response object by the application.

The response object's out property is a file-like object that can be used for writing the body of the response.

class MyHandler(webapp.RequestHandler):
    def get(self):
        self.response.out.write(
            '<!doctype html><html><body><p>Hi there!</p></body></html>')

The out stream buffers all output in memory, then sends the final output when the handler exits. webapp does not support streaming data to the client.

The clear() method erases the contents of the output buffer, leaving it empty.

If the data written to the output stream is a Unicode value, or if the response includes a Content-Type header that ends with ; charset=utf-8, webapp encodes the output as UTF-8. By default, the Content-Type header is text/html; charset=utf-8, including the encoding behavior. If the Content-Type is changed to have a different charset, webapp assumes the output is a byte string to be sent verbatim.

Note: While the Request class is derived from the WebOb library, the Response class is not. However, the Response class includes several methods that behave similarly to the WebOb equivalent. (A future version of the API may use the WebOb class directly.)

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.