Coding,  Technology

How to Deploy Python Flask Application on IIS

I wrote an article on how to run python Flask application on Apache Server on a Windows machine. The setup is so tricky that I thought I should write another article on running python Flask Application from an IIS server. I hope this helps some one.

  1. If you don’t already have IIS installed go to Start->contol panel->Programs->Programs and Features->Turn Windows Features on or Off
  2. Make Sure CGI is installed
  3.  Now go to this previous post on How to Deploy Python Flask Application with Apache on a Windows Server and Follow the instructions up to number 12. It will show you how to install python and run the Develoment Server for python and come back and continue from here.
  4. Install wfastcgi by running pip install wfastcgi from the command line. And copy the file from C:\Python34 to the root of your application. C:\myapp\app
  5. Now open the command line as admin and  Run
C:\Windows\System32>cd /myapp/app
icacls . /grant "NT AUTHORITY\IUSR:(OI)(CI)(RX)"
icacls . /grant "Builtin\IIS_IUSRS:(OI)(CI)(RX)"

The codes above allows IIS to read and execute the files in the directory of your application. It took me a week to figure this out. Trust me this can be a nightmare if you do not run those two commands. It will look like this

5. Now open IIS and create a new website with the root at your application like this

6. Now click on the name of your website in IIS on the left and click on Handle Mapping as show below

6. Click on Add Module Mapping on the right and complete the fields on the forms like so

Before you click on OK, click on Request Restrictions and uncheck the box that says Invoke handler only if request is mapped to:

Click on OK and OK again to save the changes

7.  Now click on the server name on the left and Go to the root server settings and click “FastCGI Settings”:

8. Double Click on the python handler for your application and click on the Environmental Variable Collections with the “…” as show on the image below

9. Set the PYTHONPATH like the image below where by the Value is the path to your application in my case it is C:\myapp\app

10. Set the WSGI_HANDLER which in this case is the name of your application file. If yours is the make it in my case it is so it will be

11. Now go to your browser and type in http://localhost and you will see


Now you have IIS running python website. Let me know if you have any questions.

Note: Don’t forget to install wfastcgi by running pip install wfastcgi from the command line. And move the wfastcgi file to the root of your application.

Useful links

install wfastcgi  –

Another tutorial  –

Another breakdown –


If you enjoyed this article, share or tell a friend and be on the lookout for more from

Sharing is caring!


  • bisygaks

    Good site! I truly love how it is simple on my eyes and the data are well written. I am wondering how I might be notified when a new post has been made. I have subscribed to your RSS feed which must do the trick! Have a nice day!

  • bisygaks

    Howdy would you mind letting me know which web host you’re working with? I’ve loaded your blog in 3 completely different internet browsers and I must say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a honest price? Kudos, I appreciate it!

  • furtdso linopv

    We stumbled over here by a different web page and thought I might check things out. I like what I see so now i am following you. Look forward to going over your web page for a second time.

Leave a Reply

Your email address will not be published. Required fields are marked *

So glad to see you sticking around!

Want to be the first one to receive the new stuff?

Enter your email address below and we'll send you the goodies straight to your inbox.

Thank You For Subscribing

This means the world to us!

Spamming is not included! Pinky promise.