Re: How to run python scripts on apache?

Graham Dumpleton <[email protected]> Tue, 6 Oct 2009 12:17:03 +1100
Newsgroups gmane.comp.python.mod_python
Message-ID <[email protected]>
2009/10/6 ejaz shah <[email protected]>:
> 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.

See:

  http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

Graham