我将此添加到IIS上的处理程序模块中,用于我的网站
Request Path: *.py
Executable: "C:\Program Files\Python 3.5\python.exe"
Name: Python
我将IIS用户的权限授予此路径C:\ Program Files \ Python 3.5 \
然后我创建了这个test.py文件来测试我的配置
print("Content-Type: text/html")
print("")
print("""\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
""")
但是当我尝试通过http://localhost/test.py
加载时,我收到了此错误网关错误The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:""
我缺少什么想法?
答案 0 :(得分:1)
如Microsoft's manual所示(链接中有更详细的描述):
测试响应(python 2,转换应该很容易):
print
print 'Status: 200 OK'
print 'Content-type: text/html'
print
print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>'
print '<BODY>'
print '<H1>This is a header</H1>'
print '<p>' #this is a comment
print 'See this is just like most other HTML'
print '<br>'
print '</BODY>'
似乎为您添加了Content-Length
标题,您应该添加Status
标题。