(This instruction is based the post here, with added details).
- Make sure Python is installed properly (I’m using Python 2.7.1 in this example).
- If you don’t have IIS CGI module installed, you can go to Control Panel->Programs and Features, and then click on “Turn Windows features on or off”. Then, in “Windows Features” window, make sure Internet Information Service->World Wide Web Services->Application Development Features->CGI is checked (IMG 1). Click “OK” to apply changes.
- Launch IIS Manager (Control Panel->Administrative Tools->Internet Information Services (IIS) Manager).
- Right click on “Default Web Site” and select “Add Application…”.
- Enter an application Alias, and specify a local path where you’ll put your Python scripts (IMG 2). Click “OK”.
- With the new application node selected, double-click on “Handler Mappings” in the middle panel. Then, click “Add Script Map…” link in “Actions” box to the right.
- In “Add Script Map” window, enter “*.py” as Request Path, and your python.exe as Executable. Note two parameters (-u %s) are added to the command line. Give the mapping a name (such as “Python”) and then click “OK”.
- Create a new Python script in your script folder in step 5. Note that you’ll need to return complete HTTP header for your script to work:
print "Status: 200 OK"
print "Content-Type: text/plain;charset=utf-8"
print
print "Hello Python!" - Launch browse and navigate to the script (http://localhost/PythonApplication/HelloPython.py) to see the result.
IMG 1: IIS CGI Module
IMG 2: Application settings.
IMG 3: Python mapping.
0 comments:
Post a Comment