How to deploy Streamlit on Windows IIS?

Has anyone successfully deployed a Streamlit application using Windows Server / IIS?

I’ve looked through every related post in this forum, and can only see one person who claims they have achieved it here: Simplest way to deploy a streamlit app in Windows server 2012 - Using Streamlit - Streamlit, but that method proved not to work for other users (my team included). Every other thread on the topic in this forum just runs dry!

Situation:

  • We are trying to host our new Streamlit app in a Windows VM using IIS (where we have a number of Flask/Dash apps already hosted)
  • We can run the app fine from within the VM (with streamlit run app.py)
  • We have followed the instructions listed in the above link (which is also linked to from the official ‘Deployment’ thread)
  • Visiting the address/port just returns “The Web server is configured to not list the contents of this directory.”, which means the app is not running and the server is looking for some default html to display when it gets no response

Any help would be immensely appreciated! :relaxed:

2 Likes

Also interested in this and the linked post also did not work - if you found a solution, could you post it here?

We managed to deploy in a Windows VM by avoiding IIS altogether and just using Task Scheduler. Perhaps a sub-optimal solution but worked a dream for our use case:

  • Create a batch file that simply contains streamlit run app.py (or perhaps also activates your virtualenv if you are using one) in the same directory as app.py
  • Open Task Scheduler, and create a new task
  • In the new task dialogue:
    • in General make sure to have ‘Run whether user is logged in or not’ checked
    • Create a new Trigger, we just used a daily trigger at 3am
    • Create a new Action. Set ‘Action’ to ‘Start a program’ and Browse for the batch file you created above
    • In Settings, at the bottom under ‘If the task is already running, then the following rule applies:’ select ‘Do not start a new instance’

What you end up with is an automated task that goes to start-up your app every night at 3am, unless its already running, in which case, keep the current one running!

We also specified which port we wanted to use etc. in the .streamlit/config.toml file. Plenty of docs around for that side of things.

Worked for us!