#! "C:/Python27/python.exe"
print "Content-Type: text/html\n"
print "Hello cgi!"
Note that :
1. shebang operator pointing to the python installation is necessary, if not provided you will see error something like shown below in Apache logs
[Mon Dec 01 01:00:56.068334 2014] [win32:error] [pid 1536:tid 840] [client 127.0.0.1:49361] AH02102: C:/wamp/www/python/test2.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
[Mon Dec 01 01:00:56.068334 2014] [cgi:error] [pid 1536:tid 840] (9)Bad file descriptor: [client 127.0.0.1:49361] AH01222: don't know how to spawn child process: C:/wamp/www/python/test2.py
2. \n in the content type declaration, if not provided you will see an error like below in Apache logs
[Mon Dec 01 00:54:34.997014 2014] [cgi:error] [pid 1536:tid 840] [client 127.0.0.1:49210] malformed header from script 'test2.py': Bad header: Hello cgi!
3. Note that this file need to be placed in the same directory that you have enabled for cgi execution in previous blog post and it need to be called with the URL as: http://localhost/python/testing.py
No comments:
Post a Comment