Would you like to learn how to install IIS and enable the Python CGI feature on a computer running Windows? In this tutorial, we are going to show you how to enable the Python CGI feature on the IIS server.
• Windows 2012 R2
• Windows 2016
• Windows 2019
• Python 3
• IIS
Windows Tutorial:
On this page, we offer quick access to a list of Windows tutorials.
Tutorial Windows – IIS Installation
Open the Server Manager application.
Access the Manage menu and click on Add roles and features.
On the Server Roles screen, select the option named: Web Server IIS.
Click on the Next button.
On the following screen, click on the Add features button.
On the Features screen, click on the Next button.
On the Role service screen, click on the Next button.
On the Summary screen, click on the Install button.
Congratulations! You have finished the IIS service installation on a computer running Windows.
Tutorial IIS – Enabling the CGI feature
Open the Server Manager application.
Access the Manage menu and click on Add roles and features.
On the Server Roles screen, expand the entry named: Web Server IIS.
Access the Application development menu and select the option named: CGI
Click on the Next button.
On the Features screen, click on the Next button.
On the Summary screen, click on the Install button.
Congratulations! You have finished the CGI feature installation on IIS.
Tutorial Windows – Python Installation
Access the Python website and download the latest version of the Python installer.
In our example, we downloaded the file named: Python-3.8.4-amd64.exe
As the administrator, start the Python installation.
Select both checkboxes on the bottom of the screen.
Click on the button to customize the Python installation.
Select all checkboxes and click on the Next button.
Select the checkbox named: Install for all users.
Change the Python installation path to the Root of drive C.
Click on the Next button.
Wait for the Python installation to finish.
In our example, Python was installed on the following directory.
Reboot the computer.
Congratulations! You have finished the Python installation on Windows.
Tutorial IIS – Enable Python on the IIS server
Start the application named: IIS Manager.
On the IIS Manager application, select your IIS server name.
On the right part of the screen, access the option named: Handler Mappings
Select the option named: Add Script Map
Perform the following configuration:
• Request Path – *.py
• Executable – C:\Python\Python38\python.exe %s %s
• Interpreter – Python Interpreter
Click on the OK button.
If the following message is presented, click on the Yes button.
Restart the IIS service.
Congratulations! You successfully enabled Python on the IIS server.
Tutorial IIS – Creating a Python page
Start a new DOS command-line prompt.
Use the PIP application to install a Python library named ART.
In our example, we are going to use this library to create a test page.
Access the IIS root directory.
Create a Python test page.
Use the Notepad application to open the Python test page.
Replace its content with the following code.
Open your browser and enter the IP address of your web server plus /test.py.
In our example, the following URL was entered in the Browser:
• http://172.31.7.220/test.py
The Python page should display the following message.
Congratulations! The Python extension was installed successfully on IIS.