1、安装ActiveState2.5
2、在“ISAPI和CGI限制”,添加Python扩展,注意在添加路径时 在Python.exe后加 %s %s ,如:C:\Python25\Python.exe %s %s
3、在“处理程序映射”中添加扩展名为.py的影射,路经的输入方法同上。添加之后挥在列表中看到刚才所添加的映射属于CGImodule,也就是.py扩展名的文件将以CGI方式执行。

经过这两步以后,Python脚本就可以在IIS7上运行了,如下测试


test.py

在IIS7中设置Python的ISAPIprint
在IIS7中设置Python的ISAPI
print 'Status: 200 OK'
在IIS7中设置Python的ISAPI
print 'Content-type: text/html'
在IIS7中设置Python的ISAPI
print
在IIS7中设置Python的ISAPI
在IIS7中设置Python的ISAPI
print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>'
在IIS7中设置Python的ISAPI
print '<BODY>'
在IIS7中设置Python的ISAPI
print '<H1>This is a header</H1>'
在IIS7中设置Python的ISAPI
在IIS7中设置Python的ISAPI
print '<p>' #this is a comment
在IIS7中设置Python的ISAPI
print 'See this is just like most other HTML'
在IIS7中设置Python的ISAPI
print '<br>'
在IIS7中设置Python的ISAPI
print '</BODY>'

此外Python脚本还可以借住asp引擎,以ISAPI方式执行
testpy.asp

在IIS7中设置Python的ISAPI<%@LANGUAGE=Python%>
在IIS7中设置Python的ISAPI
<HTML>
在IIS7中设置Python的ISAPI
<head></head>
在IIS7中设置Python的ISAPI
<body>
在IIS7中设置Python的ISAPI
<h1>Python Test</h1>
在IIS7中设置Python的ISAPI
在IIS7中设置Python的ISAPI
<%
在IIS7中设置Python的ISAPI
#do some python stuff here
在IIS7中设置Python的ISAPI

在IIS7中设置Python的ISAPIResponse.Write(
'Python Test<br>')
在IIS7中设置Python的ISAPIResponse.write(
'<h3>Smaller heading</hr>')
在IIS7中设置Python的ISAPI
%>
在IIS7中设置Python的ISAPI
在IIS7中设置Python的ISAPI
</body>
在IIS7中设置Python的ISAPI
</html>

相关文章:

  • 2022-12-23
  • 2022-01-23
  • 2022-01-16
  • 2022-02-03
  • 2021-05-15
  • 2022-12-23
  • 2021-06-12
猜你喜欢
  • 2022-12-23
  • 2021-08-30
  • 2021-10-05
  • 2021-09-20
  • 2021-06-06
  • 2021-07-31
  • 2022-12-23
相关资源
相似解决方案