mod_python and .py

Darryl Clarke smartssa at gmail.com
Fri Jul 14 15:06:54 UTC 2006


On 7/14/06, Michael Beattie <mtbeedee at gmail.com> wrote:
> I am trying to set up my apache2 server to handle .py files in my root
> directory with mod_python.  I have the Directory directive with the
> things enabled...
>
> <Directory /var/www/>
>                 Options ExecCGI Indexes FollowSymLinks MultiViews
>                 AllowOverride None
>                 Order allow,deny
>                 allow from all
>
>                 AddHandler mod_python .py
>                 PythonHandler mod_python.publisher
>                 PythonDebug On
> </Directory>
>
> I have tried various settings and I cant seem to get it to handle .py
> with mod_python.  If I change the file to .cgi, it starts handling it
> as CGI which is great, but it's not what I want.  What directives do I
> need that I am missing here?

Hmm... I'm not 100% familliar with the publisher module, but try this:

PythonHandler test

and put a file called 'test.py' in your www directory, then go to it
and see if it works.
http://yourhost/test.py

A simple test.py:
--
from mod_python import apache

def handler(req):
        req.content_type = 'text/plain'
        req.write("Hello World!")
        return apache.OK
--

That works for me, but when I use the publish handler, it fails (it
sends me the .py file!)  So, this could very well be a bug.

Try that and see what happens...

-- 
~ Darryl  ~ smartssa at gmail.com
~ http://darrylclarke.com




More information about the ubuntu-users mailing list