[PYTHON] [Easy detonation velocity 2nd] Deploy Streamlit to heroku

Synopsis up to the last time

Previous article

I made a web app at explosive speed using Streamlit, Python's open source framework.

This flow

I will add the necessary files to the directory of the web application created with Streamlit and develop it on heroku. What you need

requrements.txt It makes the server aware of what it needs to download in order to execute the code. Add streamlit and numpy and pandas as needed. Below is an example.

requrements.txt


streamlit==0.60.0
matplotlib==2.2.3 
numpy==1.15.1

App not compatible with buildpack I get an error requirement.txt make runtime.txt Procfile

setup.sh Like requirements.txt, setup.sh creates an environment where the app runs on the server. Please change the email individually.

setup.sh


mkdir -p ~/.streamlit/

echo "\
[general]\n\
email = \"[email protected]\"\n\
" > ~/.streamlit/credentials.toml

echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml

Procfile It describes what command the server should execute.

web: sh setup.sh && streamlit run {name_of_app}.py

Deploy

First login

$ heroku login

Since heroku uses Git, it always initializes the Git repository.

$ git init
$ git add .
$ git commit -m "first commit"

Then create a new instance on heroku.

$ heroku create

All you have to do is push and open it.

$ git push heroku master
$ heroku open

I also tried deploying an application that can solve TSP by the 2-opt method.

TSP_app.mov.gif

Finally

This time, I deployed Streamlit, which allows you to easily shape the deliverables with just Python. It was very explosive until deployment. If you want to know the convenience of Streamlit itself and the detonation velocity, please see Previous article! !!

Next article

Recommended Posts

[Easy detonation velocity 2nd] Deploy Streamlit to heroku
Deploy a web app created with Streamlit to Heroku
Deploy django project to heroku
How to deploy a Streamlit application to GCP (GAE)
Deploy to Heroku right away without knowing git.
Django Heroku Deploy 1
Detonation velocity python-fire
Django Heroku Deploy 2