走过路过千万不要错过python开发——iis部署python运行环境

IIS部署

1.启用或者关闭windows功能,选择安装CGI,我这里已经安装过了。

 

 2.安装后重新打开IIS看到CGI

 

 

3.配置ISAPI和CGI限制

 

 4.右上角添加,路径是python安装路径,注意要加上两个 %s %s

点确定

 

5.处理映射关系

 

6.右上角  添加模块,模块选择:CgiModule 

出现弹出框,点“是”

添加完成

 

 

 

7.接下来测试一下,创建一个网站

 

 

 

 

服务器端测试代码:

复制代码
 1 #!/usr/bin/python
 2 import cgi
 3 import json
 4 #!/usr/bin/python
 5 # print ("Content-Type: text/html")
 6 # print ("")
 7 # print ("<html>")
 8 # print ("<h2>CGI Script Output</h2>")
 9 # print ("<p>This page was generated by a Python CGI script.</p>")
10 # print ("</html>")
11 def main(): 
12     print ("Content-type: text/html\n")
13     form = cgi.FieldStorage()
14     print(form.keys())
15     print(type(form))
16     if form.keys() and form["ServiceCode"].value != "":
17         print ("<h1> Hello",form["ServiceCode"].value,"</h1>" )
18 
19     else:   
20         print ("<h1> Error! Please enter first name.</h1>")
21 main()
复制代码


经过测试OK!!!

 联系我们

  • 邮箱:admin@admincms.top
  • 官方博客:blog.admincms.top
  • 官方微信公众号:huayuejishu
扫描二维码关注Joker.Liu微信公众号
TOP博客官方微信公众号二维码