As part of my “Cloud Programming” track at TEC 20ii I’m presenting an introduction to Google App Engine.  I’ll be making any updates / corrections to the Google Presentation here:

Introduction to Google App Engine

These slides cover installing Google App Engine on Windows and writing your first application.  It includes a very simple introduction to the datastore.

Warning:  Don’t build a hit counter this way – this is just a simple way to introduce App Engine, but should not be used in production.  Counting records is a slow operation in distributed databases, and this will actually read each record to get the count.  There are better but more complicated ways to do this.

app.yaml:

application: myfirstapp
version: 1
runtime: python
api_version: 1

handlers:
– url: .*
script: main.py

main.py snippet (broken):

class MainHandler(webapp.RequestHandler):
def get(self):
hit = HitInfo(useragent = self.request.headers['User-Agent'])
hit.put()
hits = HitInfo.all().count()
self.response.out.write('Hello number '+hits)

main.py snippet (corrected):

class MainHandler(webapp.RequestHandler):
def get(self):
hit = HitInfo(useragent = self.request.headers['User-Agent'])
hit.put()
hits = HitInfo.all().count()
self.response.out.write('Hello number '+str(hits))

Advertisement