User Interface
- Create a Git Repo
Note: Heroku allows deployment using Git or Docker.
git init
- Build your App
import streamlit as st
import pandas as pd
import numpy as np
def main():
# Your Code
if __name__ == "__main__":
main()
- Test your App (Local Environment)
~$ streamlit run app.py
- Create your requeriments.txt file
This file contains the libraries that your code needs to work. To do this, you can use pipreqs
.
pipreqs /path/to/your/app/
After this command, a requirements.txt will be created in the folder of your app
matplotlib==3.1.0
streamlit==0.56.0
pandas==1.0.2
seaborn==0.9.0
numpy==1.16.3
- Setup.sh and Procfile
Heroku needs these files for starting the app
- setup.sh : create a streamlit folder with both credentials.toml and config.toml files.
- Procfile : This file executes the setup.sh and then call streamlit run to run the app
# Setup.sh
mkdir -p ~/.streamlit/
echo "\
[general]\n\
email = \"your-email@domain.com\"\n\
" > ~/.streamlit/credentials.toml
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml
# Procfile
web: sh setup.sh && streamlit run app.py
- Create a Heroku Account
Create a free account
- Install Heroku CLI
- Login into Heroku CLI
Move to your App folder and execute heroku login
- Deploy the App
Deploy your app by running heroku create
in your app folder
- Check it
Check your app by running heroku ps:scale web=1
After that, push your code
git add .
git commit -m "message"
git push heroku master
- Open it
Open your app using heroku open
Thanks to Gilbert Tanner for his tutorial