I just did this in 5 minutes.
Ensure you have IIS. run:
%windir%\system32\OptionalFeatures.exe
. Or, via pointy-clicky: Start…Control Panel…Programs and Features… (and then on the left hand side) Turn Windows Features on or Off. Make sure CGI is installed, under the IIS node.Download Python for Windows, from python.org . I grabbed Python2.7. Make sure you get the x64 version if you have an x64 version of Windows.
Unpack and install that python MSI. Choose the default, which puts python into
c:\Python27
Create a directory to hold your “development” python scripts. Eg,
c:\dev\python
Set the permissions on the files in the directory
c:\dev\python
to allow IIS to read and execute. Do this by running these two icacls.exe commands from the command line:cd \dev\python icacls . /grant "NT AUTHORITY\IUSR:(OI)(CI)(RX)" icacls . /grant "Builtin\IIS_IUSRS:(OI)(CI)(RX)"
Open IIS manager. Run
%windir%\system32\inetsrv\iis.msc
, or do this via the control panel: Start…Control Panel…Administrative Tools…Internet Information Services (IIS) Manager. Create a new application. Specify the virtual path as/py
and the physical path asc:\dev\python
.Within that IIS application, add a script map for
*.py
, and map it toc:\python27\python.exe %s %s
create a “HelloWorld.py” file in
c:\dev\python
with this as the content:print('Content-Type: text/plain') print('') print('Hello, world!')
invoke
http://localhost/py/helloworld.py