Tiny Python web service
I had an excessive amount of fun today doing some yak shaving. There's this CSS mangling script I'm writing for Naaya, that compares different versions of a file, and we need to run it on many sites, so I decided to package the main code as a web service, and deploy a minimal runner script on each site.
The shaved yak was, of course, a spiffy web service wrapper. It's running behind mod_wsgi, with URL dispatching and request/response objects by Werkzeug, logging to a StringIO that can be sent out with the response, a view that serves static content, another one that serves Genshi templates, a couple of others for JSON and repr output, and, the application auto-reloads when a source file is changed – all this in 99 lines of code, including blank lines and comments. Python is pure awesomeness. :)
The code is up on gist: wsgiapp.py. I think it's useful as a working example of a nicely rounded web service using the latest and greatest libraries from the Python world.