在 IIS 5.1 上设置 Python

发布于 2024-07-16 03:48:44 字数 882 浏览 2 评论 0原文

我有这个测试 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉墨 2024-07-23 03:48:44
C:\Python30\python.exe -u "%" "%"

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

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

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

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文