How to deploy streamlit app to Heroku

Hello everyone,
This is a step by step tutorial about how to deploy your Streamlit app to Heroku.

What is streamlit?

Streamlit is an open-source python framework for Machine Learning and Data Science teams and individuals.
See it yourself: h…


This content originally appeared on DEV Community and was authored by Kevork Keheian

Hello everyone,
This is a step by step tutorial about how to deploy your Streamlit app to Heroku.

What is streamlit?

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

Requirements:

  • python installled
  • streamlit installed (You can install streamlit using pip install streamlit)
  • GitHub account

Once the above are installed

You can check their documentation about creating you app.

And now it's time to deploy ?

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.

Now head over to GitHub and create a new repository and publish your code to github. You can check this article to see how you can do that.

Once the code is on GitHub head over to Heroku and create a new app:
Create a new app on Heroku

Choose a name to your app and click "Create app"

Heroku - create a new 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.
Heroku - choose deployment method

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.

Heroku - manaul deployment

Note: the app is no longer available on heroku


This content originally appeared on DEV Community and was authored by Kevork Keheian


Print Share Comment Cite Upload Translate Updates
APA

Kevork Keheian | Sciencx (2021-09-20T09:00:44+00:00) How to deploy streamlit app to Heroku. Retrieved from https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/

MLA
" » How to deploy streamlit app to Heroku." Kevork Keheian | Sciencx - Monday September 20, 2021, https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/
HARVARD
Kevork Keheian | Sciencx Monday September 20, 2021 » How to deploy streamlit app to Heroku., viewed ,<https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/>
VANCOUVER
Kevork Keheian | Sciencx - » How to deploy streamlit app to Heroku. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/
CHICAGO
" » How to deploy streamlit app to Heroku." Kevork Keheian | Sciencx - Accessed . https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/
IEEE
" » How to deploy streamlit app to Heroku." Kevork Keheian | Sciencx [Online]. Available: https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/. [Accessed: ]
rf:citation
» How to deploy streamlit app to Heroku | Kevork Keheian | Sciencx | https://www.scien.cx/2021/09/20/how-to-deploy-streamlit-app-to-heroku/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.