The following steps show how to set up the installed Python interpreter as a script engine for use with IIS and ASP.
- Make sure that the Web site containing the Python scripts has an application set up. To do this, perform the following steps:
- In the Internet Service Manager (ISM), right-click the directory that is the application starting point, and then click Properties.
- Click the Home Directory, Virtual Directory, or Directory tab.
- Under Application Settings, verify that the Name text box is active, and that it contains a name.
- If the dialog box is inactive, click Create to create an application, and then give the application a name (the default name is "Default Application").
- Under Permissions, verify that Execute (including script) is selected.
- Verify that application mapping for .py files is set up. To do this, perform the following steps:
- In the ISM, under Internet Information Server, right-click the computer name, and then click Properties.
- From the Master Properties drop-down list, click WWW Service and then click Edit.
- Click the Home Directory tab, and then click Configuration.
- To add the application mapping, click Add, and then create a new mapping by using the following information (substituting the correct path on your computer):
- Executable: "C:\Python20\python.exe %s %s" (The two "%s" after the executable are required for console-based script interpreters but would not be required for an Internet Server API [ISAPI]-based script interpreter).
- Extension: .py
- Script engine: selected.
- Check that File Exists: selected (for security) Click OK.
- Verify that the file and directory permissions are set correctly in the computer's access control list (ACL). For anonymous access, the IUSR_[computername] and IWAM_[computername] user accounts must have at least "read" permission (RX). When using other types of password authentication, the permissions required may vary.
Create a file in a text editor such as Microsoft Notepad, and include the following lines of code. Save the file in the scripts folder as Test.py.
print 'Status: 200 OK'
print 'Content-type: text/html'
print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>'
print '<H1>This is a header</H1>'
print '<p>' #this is a comment
print 'See this is just like most other HTML'
Browse "Test.py" on the Web site:
#do some python stuff here
Browse "Python.asp" on the Web site:
The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.
Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.
Article ID: 276494 - Last Review: Jun 19, 2014 - Revision: 1