[mod_python] How to run python scripts on apache?

ejaz shah ejazshah85 at gmail.com
Tue Oct 6 15:32:27 EDT 2009

Hi All,

As per your advice I have integrated mod_wsgi by following instructions at
the following site and it is working fine.

Now what I want to know is that if I want to execute other .py extension
files what should I do? Should I copy paste all my .py files in wsgi_app
directory as mentioned in the link?

I tried doing that but it dint work.
I have a simple .py file named as message.py the content of which is as

# file: message.py
 print "When that Aprill with his shoures soote";
 print "The droghte of March ath perced to the roote,";
 print "And bathed every veyne in swich licour";
 print "Of which vertu engendered is the flour...";

Now in my wsgi_app directory there are two files. So when I run
localhost:8085/wsgi it gives error. What I want is that on running it
through my server it should list down all .py files and on clicking any of
them should result in execution of .py file. One more thing I need to know
is how should a python file be written to be executed through server? How to
pass request and response paramaters? For eg how can I define my messgae.py
file to be executed? or it is correct the way it is mentioned?

Kindly help me.


Ejaz Shah

On Tue, Oct 6, 2009 at 6:32 AM, Bart <scarfboy at gmail.com> wrote:

> On Tue, Oct 6, 2009 at 3:08 AM, ejaz shah <ejazshah85 at gmail.com> wrote:
> > 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!!..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20091006/0d940509/attachment.html

More information about the Mod_python mailing list