views:

131

answers:

2

In my Apache webserver I put this:

<Directory /var/www/MYDOMAIN.com/htdocs>
    SetHandler mod_python
    PythonHandler mod_python.publisher
    PythonDebug On
</Directory>

Then I have a handler.py file with an index function.

When I go to MYDOMAIN.com/handler.py, I see a web page produced by the index function (just a plain vanilla HTML page). Every other page is of this type: MYDOMAIN.com/handler.py/somename where somename corresponds to a funcion in handler.py file.

But when I go to MYDOMAIN.com, I get this:

Not Found

The requested URL / was not found on this server.

Is theres a way with mod_python and publisher to just use the root and not a name.py as a starting point?

I already tried with this in the apache conf file:

DirectoryIndex handler.py

To no avail :(

A: 

Try creating an empty file called index (or whatever) in the directory and then use

DirectoryIndex index

Seems like DirectoryIndex checking is done watching the filesystem.

Vinko Vrsalovic
+2  A: 

Yes, but you need to create your own handler. You currently use publisher, it just checks the URI and loads given python module.

To create your own handler you need to create a module like this (just a minimalistic example):

from mod_python import apache

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

Then you just point to it in Apache configuration.

You can still use publisher handler inside your own handler, although you can't have pretty URLs with it AFAIK.

Sebastjan Trepča