在IIS 5.1上设置Python

时间:2009-04-08 13:50:10

标签: python iis cgi iis-5

我有这个测试python文件

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>'

我在IIS 5.1上创建了一个应用程序,它具有执行脚本的权限并创建了.py的映射,如下所示:

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

但是当我尝试执行脚本时,我收到以下错误:

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 ''

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

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

关闭,但应该是“%s”。我用:

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

(第二个%s用于命令行&lt; isindex&gt;查询,这在本世纪永远不会发生。)