FANDOM


Pythonapi

Jbillsblog source code screenshot

The Python API is the most used api in Google App Engine. It has dozens of functions. This Article will give only the basic building blocks of an app.

ImportsEdit

The imports are the most important part of the app. These allow you to use the Google App Engine Python apis.

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

DatabasesEdit

The databases define the format in which you store data.

class blankdatabase(db.Model):
     blah = db.StringProperty()
     date = db.DateTimeProperty(auto_now_add=True)


ClassesEdit

The classes are where the bulk of you code will go. For instance:

class MainPage(webapp.RequestHandler):
     def get(self):
          statements


WSGI and app start codeEdit

This code starts the app and sets the urls.

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

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()