42 Deploying to Streamlit Community Cloud
The Streamlit community cloud allows you to deploy an unlimited number of web apps for free when your app is uploaded to github.
You can host an unlimited number of apps when they are hosted in public Github repositories or made publicly available, even if the code is private.
You can host one app that is not publicly available; however, note that this will still make use of Streamlit’s server’s, which are located in the USA, so are not suitable for sensitive data.
Each individual app will have limits on the amount of memory, which in turn impacts the number of concurrent (simultaneous) users, though it’s difficult to put an exact number on how many concurrent users can be supported for an app given how different each app is in terms of memory requirements.
42.1 Deploying an App
42.1.1 Method 1 - From the deployed app
Before undertaking this step, you will need to have uploaded your repository to Github.
:::{.callout-tip} While Streamlit has some common packages available by default, it’s best to provide a requirements.txt
file, and you will need to do this for any non-standard Python packages.
If you are using the hsma_webdev
environment, you can copy the requirements.txt
file from either module 7B or 7C in the HSMA course.
pandas==2.2.2
numpy==1.26.4
simpy==4.0.2
matplotlib==3.9.1.post1
plotly==5.23.0
streamlit==1.37.0
streamlit_folium==0.22.0
folium==0.17.0
geopandas==1.0.1
palmerpenguins==0.1.4
ipykernel==6.29.5
ipython==8.27.0
wordcloud==1.9.3
openpyxl
nbformat>=4.2.0
fiona==1.9.0
You can then run the app as normal from the terminal in VSCode.
At the top right of the app, there will be a ‘deploy’ button. Click on this.
In the pop-up that appears, click on the ‘deploy now’ button for the option on the left.
If you have not previously followed this process, you will be asked to authorize Streamlit to link with your Github account.
You should not need to change the values for ‘Repository’, ‘Branch’ or ‘Main File Path’.
If your app is in a subfolder, you may need to change the slashes that
Enter an App URL if you don’t want to use an autogenerated Streamlit one. This can contain letters, numbers and hyphens.
Next, click on ‘Advanced settings’.
The HSMA webdev environment used in module 7 of the course uses Python 3.11, so it’s best to select this from the dropdown.
You can’t change the Python version for a deployed app at a later stage - you would have to delete the app from your community cloud and start the deployment process again.
You don’t need to worry about the Secrets file for now.
Click ‘Save’.
Now you should be back on the original screen, and can click ‘Deploy’.
42.1.2 Method 2 - From the Streamlit Community Cloud Website
For subsequent apps, you may find it quicker to navigate to https://share.streamlit.io/ and choose ‘Create App’.
You will first need to log into Streamlit community cloud using your Github account.
Choose ‘Yup, I have an app’.
Fill in the required details.
Clicking on the ‘repository’ field will give you a scrollable list of all repositories available in your Github.
When you’re ready, click deploy.
42.2 Managing your community cloud apps
Navigating to https://share.streamlit.io/ will give you an overview of the apps you have published to the community cloud.
Clicking on the three dots will allow you to delete or reboot the app, or change various settings relating to app privacy, secrets, and the app URL.
42.3 Troubleshooting your app
When loading up your app while logged into your Streamlit community cloud account, you will receive additional powers to manage and troubleshoot your app.
You should see a ‘manage app’ button at the bottom right of the screen.
Clicking on this brings up a sidebar that allows you to see the behind-the-scenes activity that occurs when the virtual machine running your app is first loaded up, along with any logging or error messages. This can give you an idea of why your app isn’t working.
Clicking on the three dots at the bottom gives you access to some useful commands, like rebooting the app.
42.4 Updating your App
New changes made to your repository should automatically be reflected in your app.
The exception to this may be changes to the list of required packages in requirements.txt
If this is the case, you may need to manually reboot the app from the list in https://share.streamlit.io/ or from within the ‘manage app’ menu when viewing your app.