Deploy Streamlit App to Heroku in 10 Minutes

Updated: Sep 10

Hello readers, I am back with another tutorial, here we are going to learn about how we can deploy the Streamlit web application to Heroku in under 10 Minutes.


Requirements

  • Running Streamlit code, which you want to deploy.

  • Requirements.txt which contains project requirements.

  • Setup. sh which will allow us to run Streamlit App.

  • Procfile which will run our application.

  • runtime.txt [Optional] If you want a specific python version.

  • GIT & Heroku CLI [Download it from the official site]




Steps


- Open CMD in your project directory, Use the following command to log in with Heroku.

heroku login

- Now think about your unique project name. In my case, it is "bankifscchecker". Now use the following in CMD. It will create an app for it. It will give you one git link. Now copy that link.

heroku create bankifscchecker --buildpack heroku/python

- Now we need to clone our empty working(bankifscchecker) repository. Use the following command.

git clone https://git.heroku.com/bankifscchecker.git

- Now copy your python code from the main directory, and paste it into this empty folder. And rename it to "App.py".

- Now we need to create "requirements.txt"

- Now we need to create Procfile. Paste the following in Procfile(Don't include any extension)

web: sh setup.sh && streamlit run App.py

- Now the last file is setup.sh .Paste the following into it.

- Now, we have done almost everything, at the end your folder tree should be like this.

- Main_Dir
    - bankifscchecker
         - requirements.txt
         - setup.sh
         - Procfile
         - App.py
         - [Content of App.py, like images, csv etx]

- Now open CMD in bankifscchecker and now we just need to commit & push all files to Heroku. Use the following command.

git add .
git commit -m "message"
git push origin master

- In CMD, you can check the logs, If everything works well then in 10-15 minutes you will get the URL of your App. URL will be like this.

https://[--YOUR_APP_NAME--].herokuapp.com/

Thanks, readers. See you in the next blog. See the full tutorial of this Heroku deployment on my youtube channel.






61 views0 comments