This is a step by step tutorial about how to deploy your Streamlit app to Heroku.
Streamlit is an open-source python framework for Machine Learning and Data Science teams and individuals.
See it yourself: https://streamlit.io
You can deploy your app using streamlit sharing, but the problem is that you only have 3 apps with the free version.
So what you will see now is how you can deploy your app to Heroku
streamlitinstalled (You can install streamlit using
pip install streamlit)
- GitHub account
Once the above are installed
You can check their documentation about creating you app.
You need to add 2 additional files to your project.
1- You need to add a setup.sh file which is used to add shell commands inside the file.
mkdir -p ~/.streamlit/ echo "\ [server]\n\ headless = true\n\ port = $PORT\n\ enableCORS = false\n\ \n\ " > ~/.streamlit/config.toml
Then add a new file called Procfile and inside it paste the following code:
web: sh setup.sh && streamlit run app.py
And finally a requirements.txt file
streamlit matplotlib numpy pandas
and the other packages that you are using in your app.
Once the code is on GitHub head over to Heroku and create a new app:
Choose a name to your app and click "Create app"
You can leave the pipeline empty for the time being and choose "GitHub" as your deployment method.
And in the Connect to GitHub section choose your username/org, type the name of the repository and click search. After you click search you can see the repo, click on the Connect button next to the repo.
Once you click connect you can see at the end of the page The Manual deploy section. Just click Deploy Branch and watch the magic happen.
Once the deployment is finished you can check your app app-name.heroku.com.
In this case we chose streamlit-heroku-app as our app name so if you need to navigate to streamlit-heroku-app.heroku.com to see the deployed streamlit app.
Note: the app is no longer available on heroku