import os, time from google.appengine.ext import db """Demonstration of Google apps. Simple CGI script that dislpays the IP addresses of last 10 visitors.""" sourceIP = os.environ['REMOTE_ADDR'] class VisitRecord(db.Model): "A simple persistent data object" source = db.StringProperty(required=True) # This should really be an int; sorting broken timestamp = db.StringProperty(required=True) # Create a record of this visit and store it vr = VisitRecord(source=sourceIP, timestamp=time.ctime()) vr.put() # Now get a list of the last 10 visitors query = db.GqlQuery("""select * from VisitRecord order by timestamp desc""") recentVisits = query.fetch(10) # Render some HTML print 'Content-Type: text/html' print '' print '

Recent visitors

' for visit in recentVisits: print '%s %s
' % (visit.timestamp, visit.source)