我为我的网站在IIS上添加了这个处理程序模块
Request Path: *.py
Executable: "C:\Program Files\Python 3.5\python.exe"
Name: Python我给IIS用户授予了这个路径C:\Program \Python3.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:""知道我错过了什么吗?
发布于 2015-06-22 15:54:51
如微软手册所示(在链接中有更详细的描述):
并且测试响应(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头。
https://stackoverflow.com/questions/30983997
复制相似问题