[Web-SIG] Fun with WSGI -- commenting middleware.
titus at caltech.edu
Sun Jan 30 03:44:47 CET 2005
I sat down today to hack out a simple commenting system for HTML
articles, and ended up using WSGI to implement a pipe-style solution.
You can see the results at
This CGI script serves HTML files from a directory hierarchy. Anyone
can attach a comment to any HTML file served by the script.
Briefly, the solution consists of two WSGI apps, one a client called
"wsgiServeFiles" and the other a middleware app called "wsgiComment".
app = wsgiServeFiles(directory)
creates a client app that will serve files out of the given directory
according to fairly simple rules.
new_app = wsgiComment(app)
creates a wrapped client app that will allow you to comment paths under
the given app.
So, to create the site above, all I did was use the WSGI CGI
implementation and run the following command:
The source code is pretty simple. I wanted something that would run via
CGI and require nothing other than local filesystem access and a Python
installation (no databases, etc.)
The code's available at
It's still pretty hacky, and comments are appreciated.
Note that the commenting system should work for any WSGI client, although I
haven't tried it for anything else yet.
More information about the Web-SIG