[mod_python] How to run python scripts on apache?

Graham Dumpleton graham.dumpleton at gmail.com
Mon Oct 5 21:17:03 EDT 2009

2009/10/6 ejaz shah <ejazshah85 at gmail.com>:
> Hi All,
> How can we enbale all python script to be executed on apache server. I know
> how to add handler to the config file but it works only for a single
> file.Changes made in the apache config file is:
>   <Directory "C:/Program Files/Apache Software
> Foundation/Apache2.2/htdocs/test/Upload/uploaddocs">
>       AddHandler mod_python .py
>       PythonHandler mptest
>       PythonDebug On
> </Directory>
> where mp.test file is as under:
>   from mod_python import apache
> def handler (req):
>         req.content_type = 'text/plain'
>         req.write("Hello World!!!")
>         return apache.OK
> So any python file when executed on server side is processed via mptest
> which no matter what that .py script want it to do it always prints out
> Hello World!!..
> I want to generalize it. Any .py shall be executed on apache.
> Kindly let me know if any one of you know about this.

Consider perhaps using mod_wsgi, it acts more like CGI in the sense of
just being able to dump separate .wsgi files  containing Python code
into directories with them being able to directly access them via URL
with no special magic.




More information about the Mod_python mailing list