IIS不会让Python脚本设置标题

我正在试图让Python与IIS 7.5工作。

我已经添加了Python的脚本处理程序:

Python脚本映射处理程序

Python本身似乎不是问题。 我已经在命令行运行脚本没有问题。 我用来testingPythonfunction的脚本如下:

print print 'HTTP/1.0 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>' 

问题是IIS似乎在执行python脚本之前将HTTP内容types标头设置为text/plain ,因为当我浏览到浏览器中的python脚本时,我得到以下输出:

test.py浏览器输出

我做错了什么,我该如何解决这个问题?

标题前应该没有任何内容。

例如你的程序应该从以下开始:

 print 'HTTP/1.0 Status: 200 OK' print 'Content-type: text/html' print