Working on getting Python to run from IIS
Following instructions from
Basically the idea is
1. Unpack and install that python MSI. Choose the default, which puts python into c:\Python27
2. Create a directory to hold the "development" python scripts. Eg, c:\dev\python
3. Set the permissions on the files in the directory c:\dev\python to allow IIS to read and execute
4. Create a new IIS application. Specify the virtual path as /py and the physical path as c:\dev\python
5. Within the IIS application, add a script map for *.py, and map it to c:\python27\python.exe %s %s
6. Create a "HelloWorld.py" file in c:\dev\python with this as the content:
print 'Content-Type: text/plain'
print 'Hello, world!'
7. Invoke http://localhost/py/helloworld.py
When the helloworld.py is invoked the result is
HTTP Error 502.2 - Bad Gateway
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
The headers it did return are "C:\Python27\python.exe: can't find '__main__' module in 'c:\\dev\\python' ".
Some articles on Python and 'CGI application misbehaved ' were read. One said to add
print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n\n";
another said add
# original from http://python.about.com/od/cgiformswithpython/ss/test_cgi_all.htm
sys.stderr = sys.stdout
from cgi import escape
Neither of these worked.
Any idea how to troubleshoot CGI or fix the problem?
Allen in Dallas