[mod_python] Mod_python, Apache, and Mime Types.

Deron Meranda deron.meranda at gmail.com
Fri Jun 2 10:52:11 EDT 2006


On 6/2/06, Gray <gray at lu5t.net> wrote:
> When I would try to browse to http://myhost/mptest.py  my browser wants
> to download the file.  Initially I thought that mod_python just wasn't
> working, but upon downloading the file and viewing it contains:  Hello
> World!.  Mod_python is parsing and outputting correctly.
>
> So I think it must be a mime-type issue.  I found the entry for in
> /etc/apache/mime.types to contain:

The mime types in Apache are only used when Apache is forced to
generate a Content-Type header because you forgot to do it.
Try doing something like,

   req.content_type = 'text/html'

near the top of your handler (before any of the content is written out).

There should be no need to edit your mime.types file, or the mime
type directives in the httpd.conf.

Oh, and in addition to using the LiveHeaders plugin for Firefox,
if you're on Linux, the command "curl" is a very useful debugging
tool.  Something like "curl -v http://your.host.com/" will show you
all the headers being exchanged back and forth.
-- 
Deron Meranda


More information about the Mod_python mailing list