How to write Python's CGI script in IIS

xiaoxiao2021-03-06  38

1. Install python; 2. Configure IIS: a. Open Administrative Tools -> Internet Information Services; b. Right-click on the website properties, enter the property settings; c. Go to the home directory page, enter the application configuration; d. Add a mapping: Executable File Write: C: /python23/python.exe "% s"% s Note Pythong path To point to the location where you install Python, pay attention to the space between parameters. Extended: .py Action Limits to: GET, HEAD, POST E. Select the script engine, select whether the check file is existing; f. All the way is determined to complete the configuration. 3. Write CGI scripts:

Import CGI # Pour to CGI Module Print 'CONTENT-TYPE: TEXT / HTML' # must, Output HTML Document Head Print # Blank Line Marking End of Http Headers # must, the document head must end with blank line cgiParameters = cgi.fieldStorage () #Get the parameter set of POST or GET # Check if it is the parameter IF not (cgiparameters.has_key ("name") and cgiparameters.has_key ("address)): # If it is not output Form, ask for fill in Name and Address Print "

"Print" Please Fill in the name and address fields. "Else: # If it is the parameter we required, the output parameter content print"

name: ", cgiparameters [ "Name"]. Value Print "

address:", cgiparameters ["address"]. Value4. Write pythong CGI scripts in IIS, is as simple as it.

转载请注明原文地址:https://www.9cbs.com/read-64554.html

New Post(0)