Matt Rajca

blog projects github twitter email

App Engine Notes

July 01, 2011

Earlier today, I released fb2cal, a backend web service that lets users view their Facebook friends’ birthdays right from a native calendaring client. Coming from a desktop development background, writing a web app on top of App Engine was a new experience for me. Some points to take away:

  • Extend templates to reuse large parts of common HTML code; think inheritance
  • Leverage the memcache when making large data store queries or performing network requests
  • To serve parts of a web app using HTTPS, add secure: always to the script handler in app.yaml

And lastly, to handle basic authentication in a subclass of RequestHandler:

	auth = self.request.headers.get('Authorization')

	if not auth:
		self.response.set_status(401, message="Authorization Required")
		self.response.headers['WWW-Authenticate'] = 'Basic realm="Secure Area"'
		return None

	parts = auth.split(' ')
	username_pass = base64.b64decode(parts[1]).split(':')

	username = username_pass[0]
	password = username_pass[1]

	# validate username and password...

Overall, I was extremely pleased with how fast, easy and inexpensive it is to host a fully-functional web app on App Engine.