Friday, October 31, 2008

Google App Engine without the App


Say you have a legacy static website -- just HTML and images -- and you'd like to host it on Google App Engine while you ponder the direction you'd like to take it in the future.

Well, in a way, you're lucky: it's much easier to port a static site to GAE, than it is to port a web app (we used to call these "dynamic" sites ... remember?) Unless you've been a Python web developer, you'll be starting from scratch if you're developing web apps for GAE.

But how do you port an entirely static site? Luckily, my wife, Olga Volchkova asked me to do just this. She wanted to see her old website, live. She built this very lovely hand-painted Fireworks/Dreamweaver site in late 2000, which we first released in early 2001, and which she hasn't touched since 2002. It looks very 2001 -- well, very much like her work in 2001, heavily influenced by the Golden Age of Russian animation from 1965 to 1985, best represented by Yuri Norstein's wonderfully gentle short films, like Hedgehog in the Fog -- and happily there wasn't a bit of code involved!

The only problem was the file quota: 1000 files is the limit for GAE. Macromedia Fireworks was profligate with files, dividing, in one case, a single page of hers into over 400! I culled that page for now ... I'll upload it as another project (Google gives you five GAE projects per cell phone number) some other time.

So, here's what an app.yaml file for a bunch of static html, htm, gif and jpg files looks like:


application: olgallerycom
version: 1
runtime: python
api_version: 1

handlers:

- url: /
static_files: index.html
upload: index.html

- url: /(.*)
static_files: \1
upload: (.*)


No Python in sight.

I use the static_files feature of app.yaml ... it is more flexible, in a sense, than static_dir. I eliminated the Python, because the collection of files already had a working structure, which I decided to preserve. It was easier than wrapping the file fetches in code and rearranging the directories.

This is fast and easy, and recommended if you need to get a legacy site up quickly. You can see the resulting sweet, gentle legacy site of Olga Volchkova, running on GAE.