Monday, May 12, 2008

Mod Python (using python in the web)

Mod_python is an Apache module that embeds the Python interpreter within the server. With mod_python you can write web-based applications in Python that will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections and other data between hits and access to Apache internals.

ModPython

How to install:

1-Download binaries for windows
2-run the installer (must have installed Python and Apache server , with same versions compatabile with the version of modPython)
3- Choose place of where Python is installed
4- Add the line into conf/httpd.conf
LoadModule python_module modules/mod_python.so

5- Add the following as a new Directory tags in the file conf/httpd.conf (Directory is a tag < >)

Directory "E:\moodle\moodle\PythonTest"
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
/Directory

Now to test it create a file with .py inside the root of apache, it will execute the function with the name handler.

To Work With forms

PythonHandler mod_python.publisher

It will pass the form into the the .py file into the function name index(), with the same names of the fields.

1 comment:

Eyad said...

in apache\logs

check the error.log