How to deploy Streamlit on Windows IIS?

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!

3 Likes