在IIS7中设置Python的ISAPI

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

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> '

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

<% @LANGUAGE = Python %>
< HTML >
< head ></ head >
< body >
< h1 > Python Test </ h1 >

<%
# do some python stuff here

Response.Write(
' Python Test<br> ' )
Response.write(
' <h3>Smaller heading</hr> ' )
%>

</ body >
</ html >

你可能感兴趣的:(python)