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!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM