mod_wsgi
is really, really simple.
Pyerweb is a really simple (~90 lines including comments/whitespace) WSGI-compliant routing-framework I wrote. Basically the WSGI API is just a function that gets passed environ
, and wsgi_start_response
, and it returns a string.
envrion
is a dict with the request info, for example environ['PATH_INFO']
is the request URI)
wsgi_start_response
which is a callable function which you execute to set the headers,:
wsgi_start_response(output_response, output_headers)
output_response
is the string containing the HTTP status you wish to send (200 OK
etc), and output_headers
is a list-of-tuples containing your headers (for example, [("Content-type", "text/html")]
would set the content-type)
Then the function returns a string containing your output.. That's all there is to it!
To run it, using spawning
you can just do spawn scriptname.my_wsgi_function_nae
and it will start listening on port 8080.
To use it via mod_wsgi, it's documentation is good, http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide and there is a django specific section
The up-side to using mod_wsgi is it's the standard for serving Python web-applications. I recently decided to play with Google App Engine, and was surprised when Pyerweb (which I linked to at the start of this answer) worked perfectly on it, completely unintentionally. I was even more impressed when I noticed Django applications run on it too.. Standardisation is a good thing!