Select Page

Die-hard windows advocate here! So when I went into virtual space to find out how to serve up Python web apps from IIS I found a lot of help and advice but it took bits and pieces of help from several resources. For me to duplicate the process in the future and for you just starting out, I hope this will be a How To all in one place.

The largest amount of help was found here for step by step with screenshots. But since this was published something has happened with the Web Platform Installer so you will need to install the components from their direct sources.

The wfastcgi project is maintained here.

  • pip install wfastcgi
  • wfastcgi-enable (I had to run this command from an Open As Admin CMD window)

The Python for Windows download page is here. The Web Platform tries to install 3.4, I read in some post that Windows only supports under 3.6 so the closes I could find on the download page is Python 3.5.4 – Aug. 8, 2017 which I have successfully installed and run on Win 10 and Win Server 2012.

Very important at the cost of several evenings Googling, it is very important to set the file and folder security on your IIS webroot AND the Python folder, <drive>:\python\python35 or whatever it is, run these two commands from CMD or Powershell window.

icacls . /grant "NT AUTHORITY\IUSR:(OI)(CI)(RX)"
icacls . /grant "Builtin\IIS_IUSRS:(OI)(CI)(RX)"

There is also info to copy the wfastcgi into your web app folder which is found \Python35\Lib\site-packages/wfastcgi.py

For web apps you may want to use Flask which can be found here.

pip install -U Flask

The following commands may be out of order but I am not sure the order of install matters. Win Die-hard Tip: Use command-line > py in place of $ python in that other OS 🙂

Create an environment
> py -3 -m venv venv
Activate the environment
> venv\Scripts\activate

Win Die-hard Tip: You can have other URL Python apps in IIS by simply adding additional PYTHONPATH and WSGI_HANDLER and pointing them to your new project folder and run.py in the root server settings and click “FastCGI Settings” Environment Variables collection from the instructions in this resource. (and don’t forget the pipe character C:\Python35\python.exe|C:\inetpub\wwwroot\mysite\wfastcgi.py )

All of the above is what worked for me but recently I found this alternative option that may be useful to others. This option seems to not use the wfastcgi, instead uses the Add Application feature from a right-click on your app root in IIS.

That’s it for now, I have a feeling this will be living breathing add to rearrange document for a while. Please comment or contribute your tips.

RESOURCES\REFERENCES