Set up Python on IIS 7.5
Use the following steps to install and set up Python® on Internet Information Services (IIS) 7.5:
-
Ensure that IIS Common Gateway Interface (CGI) is installed through role services.
-
Launch IIS Manager by selecting Control Panel > Administrative Tools > Internet Information Services (IIS) Manager.
-
Click on your website and double-click on Handler Mappings in the center panel.
-
Click Add Script Map in the Actions box to the right.
-
In the Add Script Map window, enter
*.py
as the Request Path, and python.exe as the Executable. -
Add the following two parameters at the end of the path:
-u %s
The path should have the following format:
C:\Python27\python.exe -u %s
-
Give the mapping a name (such as Python) and click OK.
-
Create a new Python script in your web folder and name it HelloWorld.py.
Note: You need to return a complete HTTP header for your script to work, as shown in the following example:
print "Status: 200 OK"
print "Content-Ty
pe: text/plain;charset=utf-8"
Updated about 1 year ago