[mod_python] How to run python scripts on apache?

Graham Dumpleton graham.dumpleton at gmail.com
Tue Oct 6 18:33:59 EDT 2009


2009/10/7 ejaz shah <ejazshah85 at gmail.com>:
> Hi All,
>
> As per your advice I have integrated mod_wsgi by following instructions at
> the following site and it is working fine.
> http://pradyumnajoshi.wordpress.com/2009/06/09/setting-up-mod_wsgi-for-apache-and-django-on-windows/

I did not recommend you follow those instructions. Not sure why you
didn't use the official mod_wsgi documentation.

See my followup to your post on mod_wsgi list.

Graham

> 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
> under:
>
> # 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.
>
> Regards,
>
> 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!!..
>>
>>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>



More information about the Mod_python mailing list