I have a file test.py at /var/www and I am using apache2 on ubuntu 10.10. I have mod_python installed and /etc/apache2/sites-available/default configured as
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
If it put
def index(req):
return "Test successful";
Then i get Test successful
And if i put
#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""
I get 404: Not found error
More can be found here
Anyone any ideas ??
Regards,
experimentX
mod_python looks for method
def index(req)by default when it tries to handle your requests, otherwise you can specify the function which you want to call in the URL. Note that function has to return a specific value.So you can do something like
The url travelsal under mod_python is illustrated here.