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)



Utility Functions

The google.appengine.ext.webapp.util package provides the following functions:

@login_required

A Python annotation for webapp request handler methods that verifies that the user is signed in with a Google account, and redirects the user to the sign-in page if not signed in. The sign-in page redirects back to the request URL.

This annotation only works for GET requests.

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import login_required

class MyHandler(webapp.RequestHandler):

    @login_required
    def get(self):
        user = users.get_current_user()
        self.response.out.write('Hello, ' + user.nickname())
run_wsgi_app ( application )

Runs a WSGI application in App Engine's CGI environment. This is comparable to using a WSGI-to-CGI adaptor such as the one provided by the wsgiref module of the Python standard library, but has several advantages: run_wsgi_app() automatically detects whether the application is running in the development server, and if so outputs errors to the browser in addition to the log. Also, CGIHandler doesn't fully accommodate long running processes and may leak data between requests through environment variables. run_wsgi_app() properly resets the environment between requests, and is the recommended way to start a WSGI app on App Engine.

Arguments

application
A WSGI application object, such as webapp.WSGIApplication .
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()

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.