[mod_python] How do I serve up .html files?

Michael C. Neel neel at mediapulse.com
Mon Aug 25 18:40:48 EST 2003


> <Directory "/path/to/document/root">
> SetHandler python-program
> PythonHandler mymodule
> </Directory>
> 
> from there, mymodule.py (located in the document root) will handle all
> requests. here's a sample to put in mymodule.py:
> 
> from mod_python import apache
> def handler(req):
>     req.content_type = 'text/plain'
>     req.write("uri: %s" % req.uri)
>     return apache.OK
> 

This will answer for all files in that directory, including images so
make sure to check the req.uri for ".html" and return an apache.DECLINED
if it's not.  Otherwise your python module will have to serve up the
images too.

Another option would be the <Files>/<FilesMatch> directives in apache,
and set it to files ending in .html.

Mike



More information about the Mod_python mailing list