0% found this document useful (0 votes)
250 views26 pages

Google Montreal Hackathon

The document provides an overview of an App Engine hackathon being held by Google Montreal, Year One Labs, and RPM. It includes information on setting up the development environment, an overview of App Engine and its services, examples of how to use the Datastore, Memcache, User Authentication and Task Queues, and customer examples using App Engine like Optimizely, WebFilings and Tap Zoo.

Uploaded by

splynch
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
250 views26 pages

Google Montreal Hackathon

The document provides an overview of an App Engine hackathon being held by Google Montreal, Year One Labs, and RPM. It includes information on setting up the development environment, an overview of App Engine and its services, examples of how to use the Datastore, Memcache, User Authentication and Task Queues, and customer examples using App Engine like Optimizely, WebFilings and Tap Zoo.

Uploaded by

splynch
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

App Engine Hackathon

Brought to you by
Google Montreal
Year One Labs
and RPM

Saturday, January 22, 2011


Step 0: http://bit.ly/gcodelabs
Click on Java or Python App Engine codelab
and set up your environment

Saturday, January 22, 2011


Coming up

Overview of App Engine


Light Coding
App Engine Services

Saturday, January 22, 2011


The App Engine Platform

Launched in 2008
Simplify web applications
Make Google’s infrastructure
available to the world

Saturday, January 22, 2011


Prove it!

Saturday, January 22, 2011


Building Blocks

Saturday, January 22, 2011


Building Blocks
ca t ion li m it
R e pli 1 0 M i n
i m it
g h n + e l
+ Hi figuratio i gh e r s iz
C o n + H

u eu es
o r e q
+ M her QPS
H i g it
+ l i m
1 0Min
+

a ge rt
st i m m it pp o
+ F a
G B l i
n ID Su
e r v i ng + 2
a d er +O p e
s i le r e
+ F

Saturday, January 22, 2011


l A P I
n e
Building Blocks h a n
+ C ays On e s t s
Al w R e q u
+ m u p
a r
+W
ca t ion li m it
R e pli 1 0 M i n
i m it
g h n + e l
+ Hi figuratio i gh e r s iz
C o n + H

u eu es
o r e q
+ M her QPS
H i g it
+ l i m
1 0Min
+

a ge rt
st i m m it pp o
+ F a
G B l i
n ID Su
e r v i ng + 2
a d er +O p e
s i le r e
+ F

Saturday, January 22, 2011


Saturday, January 22, 2011
App Engine Today
150,000+ active applications every week
100,000+ developers every month
1B+ page views per day

Saturday, January 22, 2011


Customer: Optimizely

Y-Combinator funded startup now processing 250M


events through App Engine
Saturday, January 22, 2011
Customer: WebFilings

Disruptive multi-tenant App Engine application adopted


by Fortune 500 companies.
Saturday, January 22, 2011
Customer: Tap Zoo

Consistently in Apple's Top 10 grossing applications on


the iOS App Store
Saturday, January 22, 2011
Coding

Saturday, January 22, 2011


Building Blocks

Saturday, January 22, 2011


Datastore
import datetime
from google.appengine.ext import db

class Employee(db.Model):
name = db.StringProperty(required=True)
hire_date = db.DateProperty()

e = Employee(name="Bob")
e.hire_date = datetime.datetime.now().date()
e.put()

Non-relational, Key-value store

Saturday, January 22, 2011


Datastore
// Imports...

DatastoreService datastore =
DatastoreServiceFactory.getDatastoreService();

Entity employee = new Entity("Employee");


employee.setProperty("name", "Bob");
employee.setProperty("hireDate", new Date());

datastore.put(employee);

Java can also use JDO, JPA, Objectify

Saturday, January 22, 2011


Memcache
from google.appengine.api import memcache

intro = memcache.get("intro")
if intro is not None:
return intro
else:
intro = self.render_intro()
memcache.add("intro", intro, 3600)
return greetings

# Other operators
memcache.set("key", value, time)
memcache.set_multi({ ... }, time=3600)

memcache.set(key="counter", 0)
memcache.incr("counter") # Atomically increment

Saturday, January 22, 2011


User Authentication
from google.appengine.api import users

class MyHandler(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
signout_url = users.create_logout_url("/")
greeting = ("%s <a href=\"%s\">sign out</a>" %
(user.nickname(), signout_url))
else:
signin_url = users.create_login_url("/")
greeting = ("<a href=\"%s\">Sign in</a>." %
signin_url)

self.response.out.write("<html><body>")
self.response.out.write(%s)
self.response.out.write("</body></html>")

Saturday, January 22, 2011


Task Queues
class CounterHandler(webapp.RequestHandler):
def get(self):
taskqueue.add(url='/task', params={'key': key})

class CounterWorker(webapp.RequestHandler):
def post(self):
key = self.request.get('key')
counter = Counter.get_by_key_name(key)
if counter is None:
counter = Counter(key_name=key, count=1)
else:
counter.count += 1
counter.put()

def main():
run_wsgi_app(webapp.WSGIApplication([
('/', CounterHandler),
('/task', CounterWorker),
]))
Saturday, January 22, 2011
Blobstore
uploadurl = blobstore.create_upload_url('/upload')

self.response.out.write('<html><body><form
action="%s" method="POST"
enctype="multipart/form-data">' % uploadurl)
self.response.out.write(
"""Upload File: <input type="file"
name="file"><br> <input type="submit"
name="submit" value="Submit">
</form></body></html>""")

# Handler for /upload


class UploadHandler(BlobstoreUploadHandler):
def post(self):
upload_files = self.get_uploads('file')
blob_info = upload_files[0]
# Store blob_info.key()

Saturday, January 22, 2011


XMPP
from google.appengine.api import xmpp

user = '[email protected]'
if xmpp.get_presence(user):
msg = "Hello example!"
status_code = xmpp.send_message(user, msg)
message_sent = (status_code != xmpp.NO_ERROR)

class XMPPHandler(webapp.RequestHandler):
def post(self):
message = xmpp.Message(self.request.POST)
if message.body[0:5].lower() == 'hello':
message.reply("Greetings!")

application = webapp.WSGIApplication(
[('/_ah/xmpp/message/chat/', XMPPHandler)])

Saturday, January 22, 2011


Channel API
token = channel.create_channel(user.user_id() + game_key)

template_values = {'token': token,


'me': user.user_id(),
'game_key': game_key
}

self.response.out.write(
template.render('index.html', template_values))

# Set up clientside Javascript

Saturday, January 22, 2011


Images
from google.appengine.api import images

from google.appengine.ext import db


from google.appengine.ext import webapp

class Photo(db.Model):
title = db.StringProperty()
full_size_image = db.BlobProperty()

class Thumbnailer(webapp.RequestHandler):
def get(self):
photo = Photo.get_by_id(self.request.get("id"))
img = images.Image(photo.full_size_image)
img.resize(width=80, height=100)
thumbnail = img.execute_transforms()

self.response.headers['Content-Type']
= 'image/jpeg'
self.response.out.write(thumbnail)

Saturday, January 22, 2011


Cool Libraries

Mapper: http://code.google.com/p/appengine-mapreduce/
New DB: http://code.google.com/p/appengine-ndb-experiment/
Pipeline: http://code.google.com/p/appengine-pipeline/
Async Tools: http://code.google.com/p/asynctools/
Objectify: http://code.google.com/p/objectify-appengine/

Saturday, January 22, 2011


Resources
Code Labs: http://bit.ly/gcodelabs
App Engine Docs: http://code.google.com/appengine/docs/
Google Groups: http://code.google.com/appengine/community.html
App Engine Sub-Reddit: http://appengine.reddit.com
Stack Overflow: http://stackoverflow.com/questions/tagged/google-app-engine
These Slides: http://goo.gl/z6gUN

Saturday, January 22, 2011

You might also like