Question

I have this test python file

import os

print 'Content-type: text/html' 
print 

print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>'
print '<BODY>'
print "<H1>This is A Sample Python CGI Script</H1>"
print '<br>'
if os.environ.has_key('REMOTE_HOST'):
   print "<p>You have accessed this site from IP: "+os.environ["REMOTE_HOST"]+"</p>"
else:
   print os.environ['COMPUTERNAME']

print '</BODY></html>'

I created an application on IIS 5.1 with permission to execute scripts and created a mapping to .py like this:

C:\Python30\python.exe -u "%" "%"

But when I try to execute the script I got the following error:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

C:\Python30\python.exe: can't find '__main__.py' in ''

Any idea?

Was it helpful?

Solution

C:\Python30\python.exe -u "%" "%"

Close, but it should be "%s". I use:

"C:\Python30\python.exe" -u "%s" 

(The second %s is for command-line <isindex> queries, which will never happen in this century.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top