English

Google App Engine

webapp Overview

A web application framework can simplify development by taking care of the details of the interface, letting you focus development effort on your applications features. App Engine includes a simple web application framework called webapp.

App Engine supports any Python application framework with a CGI interface. In addition, the Python 2.7 runtime supports application frameworks using the WSGI interface, which is recommended for Python 2.7. A web application framework can simplify development by taking care of the details of the interface, letting you focus development effort on your applications features.

The Python 2.5 environment includes a simple web application framework called webapp. This framework is deprecated in Python 2.7, but you can use webapp2 (which provides a nearly identical interface) instead. WebApp2 is highly compatible with WebApp1, so upgrading will not introduce sever backward-compatibility issues. That said, Google recommends that you test your application if you upgrade.

WebApp in Python 2.5

App Engine supports any Python 2.5 application with a CGI interface.

webapp is a WSGI-compatible framework. You can use webapp or any other WSGI framework with App Engine using a CGI adaptor, such as one provided by the Python standard library.

Here is a simple webapp application that uses a CGI adaptor with App Engine:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')

application = webapp.WSGIApplication([('/', MainPage)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

webapp2 in Python 2.7

Python 2.7 applications can use either WSGI or CGI to handle requests, but WSGI is preferred (see Configuring WSGI Script Handlers). Here is a simple webapp2 WSGI application:

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)