在 IIS 5.1 上设置 Python
我有这个测试 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 ''
知道吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关闭,但应该是“%s”。 我使用:(
第二个 %s 用于命令行 查询,这在本世纪永远不会发生。)
Close, but it should be "%s". I use:
(The second %s is for command-line <isindex> queries, which will never happen in this century.)