[mod_python] Installig mod_python on Win XP.

Gustavo Córdova Avila gustavo.cordova at q-voz.com
Fri May 20 10:54:50 EDT 2005


Oyvind Ostlund wrote:

>I tried to follow the steps on this site:
>http://www.xminc.com/linux/mod_python1.html
>
>But I can't get it to work. I installed Apache 2.0.54, and I have Python 2.3.5 installed. Then I installed mod_python 3.1.3. And I added this to the Apaches httpd.conf file: 
>
>---------------------
>LoadModule python_module modules\mod_python.so
>
><Directory "c:\Apache2\htdocs\python">
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
></Directory>
>---------------------
>
>Not sure if I added it the right place, but at least I managed to restart Apache afterwards. Then I made a simple python script like this:
>
>---------------------
>from mod_python import apache
>
>    def handler(req):
>        req.write("Hello World!")
>        return apache.OK
>---------------------
>
>
>
>But if I go to http://localhos/python/ then I get this error message:
>
>
>
>---------------------
>Mod_python error: "PythonHandler mptest"
>
>Traceback (most recent call last):
>
>  File "C:\PYTHON~1\Lib\site-packages\mod_python\apache.py", line 287, in HandlerDispatch
>    log=debug)
>
>  File "C:\PYTHON~1\Lib\site-packages\mod_python\apache.py", line 457, in import_module
>    module = imp.load_module(mname, f, p, d)
>
>  File "C:/Apache2/htdocs/python/\mptest.py", line 3
>
>    def handler(req):
>
>    ^
>
>SyntaxError: invalid syntax
>  
>
No, it's right there: "SyntaxError".  You've got indentation problems, 
your function definition is indented inconsistently with the import 
statement at the top, most probably.

Just put the def... statement flush to the left margin, and it'll most 
probably work.

Also, you're using "AddHandler mod_python .py", so you're going to have 
to use an URL ending in .py when testing it, something like:

    http://localhos/python/whatever.py

to make it work.

Good luck :-)

-gus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gustavo.cordova.vcf
Type: text/x-vcard
Size: 189 bytes
Desc: not available
Url : http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050520/3108f79e/gustavo.cordova.vcf


More information about the Mod_python mailing list