TSC Support Center

Questions / FAQ

Home : Customer Support Center : FAQ Index


How do I test to see if modpython is functioning correctly?

First, you must edit or create
a .htaccess file. Inside the file, insert:

AddHandler python-program .py
PythonHandler mptest
PythonDebug On

This will tell Apache how to handle a specific file. modpython,
by default, does implicitly perform any function, unless explicitly defined
by a directive (each line in the '.htaccess' file).

Next, create a file, in this case because 'PythonHandler' is set to mptest
and 'AddHandler' is of the extension .py, the file that Apache will process
as a Python script will be named mptest.py. Insert:

from mod_python import apache
def handler(req):
req.send_http_header()
req.write("Hello World!")
return apache.OK

Notice also, that indenting is very important with Python as no explicit usage of braces to enclose control structures is used.

  The Server Center. All rights reserved. Privacy Policy 


Script provided by SmartCGIs.com