Execute a python script with CGI ?

dandrigo laurent.celati at gmail.com
Fri Jun 27 06:26:24 EDT 2014


Dear all,

1/ On my windows 8, i installed apache 2.2, python 2.7.

I coded a python script. I would like to execute this python script in CGI.I
would like enable GET pattern only (no POST pattern).  

Up to now : 

*i edited these following lines of my apache httpd.conf:
----------------------------------------------------------------------------------
DocumentRoot "C:\Program Files (x86)\Apache Software
Foundation\Apache2.2\cgi-bin"
<Directory "C:/Program Files (x86)/Apache Software
Foundation/Apache2.2/cgi-bin/">
AddHandler cgi-script .cgi .py
--------------------------------------------------------------------------------

 
*i created a htacess.txt and i pasted it into the file these following lines
:
--------------------------------------------------------------------------------
# Interprétation des fichiers .py avant envoi au serveur HTTP
AddHandler cgi-script .py
Options +ExecCGI

# Fichiers index.py : indexes repertoires
DirectoryIndex index.py
--------------------------------------------------------------------------------
  
* Si i writed a python script (web service with postgresql query). At the
begining of my script, i added these folloging lines :
--------------------------------------------------------------------------------
import cgitb

cgitb.enable()

print("Content-Type: text/html;charset=utf-8")
print()
print("Hello World!")
--------------------------------------------------------------------------------

=> What do you think about my configuration? I have made ​​a mistake? I do
have one more thing? How to test our CGI? our to ensure that my cgi works
well? 
I would like enable GET pattern only (no POST pattern). 

2/ On a 2nd time, i would like to do the same operation (for the same python
script web service/ GET pattern) but on our remote LINUX server.

=> What is the difference beetween windows and linux configuration? Could
you throw light for me? 

Thanks. 

Regards. 



--
View this message in context: http://python.6.x6.nabble.com/Execute-a-python-script-with-CGI-tp5062183p5062268.html
Sent from the Python - python-list mailing list archive at Nabble.com.



More information about the Python-list mailing list