Wilt u leren hoe u IIS installeren en de Python CGI-functie inschakelen op een computer waarop Windows wordt uitgevoerd? In deze zelfstudie laten we je zien hoe je de Python CGI-functie op de IIS-server inschakelen.
• Windows 2012 R2
• Windows 2016
• Windows 2019
• Python 3
• IIS
Zelfstudie voor Windows:
Op deze pagina bieden we snel toegang tot een lijst met Windows-zelfstudies.
Zelfstudie Windows – IIS-installatie
Open de toepassing Serverbeheer.
Open het menu Beheren en klik op Rollen en functies toevoegen.

Selecteer in het scherm Serverrollen de optie: Web Server IIS.
Klik op de knop Volgende.

Klik op het volgende scherm op de knop Functies toevoegen.

Klik in het scherm Onderdelen op de knop Volgende.

Klik in het servicescherm Rol op de knop Volgende.

Klik in het scherm Overzicht op de knop Installeren.

Gefeliciteerd! U bent klaar met de installatie van de IIS-service op een computer waarop Windows wordt uitgevoerd.
Zelfstudie IIS – De CGI-functie inschakelen
Open de toepassing Serverbeheer.
Open het menu Beheren en klik op Rollen en functies toevoegen.

Vouw in het scherm Serverrollen de vermelding: Web Server IIS uit.
Toegang tot het menu Toepassingsontwikkeling en selecteer de optie: CGI
Klik op de knop Volgende.

Klik in het scherm Onderdelen op de knop Volgende.

Klik in het scherm Overzicht op de knop Installeren.

Gefeliciteerd! U bent klaar met de installatie van de CGI-functie op IIS.
Zelfstudie Windows – Python-installatie
Toegang tot de Python-website en download de nieuwste versie van de Python-installer.
In ons voorbeeld hebben we het bestand gedownload met de naam: Python-3.8.4-amd64.exe

Start als beheerder de Python-installatie.

Schakel beide selectievakjes onder aan het scherm in.
Klik op de knop om de Python-installatie aan te passen.

Schakel alle selectievakjes in en klik op de knop Volgende.

Schakel het selectievakje met de naam: Installeren voor alle gebruikers in.
Wijzig het python-installatiepad in de root van station C.
Klik op de knop Volgende.

Wacht tot de Python-installatie is voltooid.

In ons voorbeeld is Python geïnstalleerd op de volgende map.
Start de computer opnieuw op.
Gefeliciteerd! U bent klaar met de Python-installatie op Windows.
Zelfstudie IIS – Python inschakelen op de IIS-server
Start de toepassing met de naam: IIS Manager.

Selecteer in de IIS Manager-toepassing de naam van uw IIS-server.
Aan de rechterkant van het scherm u toegang krijgen tot de optie: Handler Mappings

Selecteer de optie met de naam: Scriptkaart toevoegen

Voer de volgende configuratie uit:
• Request Path – *.py
• Executable – C:\Python\Python38\python.exe %s %s
• Interpreter – Python Interpreter
Klik op de knop OK.

Als het volgende bericht wordt weergegeven, klikt u op de knop Ja.

Start de IIS-service opnieuw.
Gefeliciteerd! U hebt Python ingeschakeld op de IIS-server.
Zelfstudie IIS – Een Python-pagina maken
Start een nieuwe DOS-opdrachtregelprompt.

Gebruik de PIP-toepassing om een Python-bibliotheek met de naam ART te installeren.
In ons voorbeeld gaan we deze bibliotheek gebruiken om een testpagina te maken.
Toegang tot de IIS-hoofdmap.
Maak een Python-testpagina.
Gebruik de Kladblok-toepassing om de Python-testpagina te openen.
Vervang de inhoud door de volgende code.
Open uw browser en voer het IP-adres van uw webserver in plus /test.py.
In ons voorbeeld is de volgende URL ingevoerd in de browser:
• http://172.31.7.220/test.py
Op de Python-pagina moet het volgende bericht worden weergegeven.

Gefeliciteerd! De Python-extensie is met succes geïnstalleerd op IIS.