Publish a web application for viewing data created with Streamlit on heroku

Overview

-Last time, you can now create web apps using Streamlit ――Because it's a big deal, let's publish it --So what you made → Chocolate Ball Viewer

Premise

--Create an account on heroku (free OK) --I have a github account

App creation

Create an app by referring to here. This article does not touch on Streamlit notation.

$ streamlit run [python-file]

Now, make sure that the app is created as expected.

Deploy to heroku

This is the main part of this article. The outline of the procedure is as follows.

  1. Prepare the files needed for heroku deployment
  2. Create an app on heroku
  3. Deploy
  4. Let's check the automatic deployment

Preparation of necessary files

You need the following two files to publish your python app on heroku.

This is enough, but let's create a script to create a streamlit configuration file. It specifies the port number and so on. (It is OK to specify it as a startup option in Procfile)

Someone has put these together and created a template for publishing the Streamlit app on heroku. https://github.com/patryk-oleniuk/streamlit-heroku-template

This time I made it like this. I almost copied it from streamlit-heroku-template.

Procfile

web: sh setup.sh && streamlit run src/choco_view.py

requirements.txt (It is safer to fix the version)

pylint
pandas
scipy
matplotlib
seaborn
streamlit

setup.sh

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

Put these together and push them to github. Private repositories are also OK.

Create an app on heroku

You can also create heroku apps with commands using the CLI (the heroku tutorial is the CLI), but if you want to link with the github repository, it's easy from the web management screen. This time I will create it from the Web.

Set the service name from "Create New App" on the upper right and click "Create app".

スクリーンショット 2021-01-15 11.27.25.png

only this

Deploy

When you create, you will be able to select the deployment method. This time, select the "GitHub" tab and specify the repository to be linked.

スクリーンショット 2021-01-20 0.01.10.png

If it can be linked, it will transition to the deploy screen.

Here, if you press "Enable Automatic Deploys" to enable automatic deployment, any updates will be automatically deployed to the specified branch of the linked GitHub repository.

When you're ready, press "Deploy Branch" from the Manual Deploy menu to start deploying.

Confirm automatic deployment

Let's update the data and push it to github.

If you look at the management screen of heroku, you can see that it is deployed (fun).

did it

I am measuring chocolate ball data as a hobby, so I released an app that visualizes the measurement data (see Chocolate Ball Statistics for details). https://chocolate-view.herokuapp.com/

Flavor can be selected

ezgif.com-gif-maker.gif

Simulation of the number of purchases required to hit the silver angel

ezgif.com-gif-maker (3).gif

end

reference

Recommended Posts

Publish a web application for viewing data created with Streamlit on heroku
(Failure) Deploy a web app made with Flask on heroku
Build a web application with Django
Let's make a WEB application for phone book with flask Part 1
Build a Flask / Bottle-like web application on AWS Lambda with Chalice
Let's make a WEB application for phone book with flask Part 2
Let's make a WEB application for phone book with flask Part 4
Launched a web application on AWS with django and changed jobs
[Python] A quick web application with Bottle!
Creating a data analysis application using Streamlit
Run a Python web application with Docker
Launch Flask application with Docker on Heroku
I made a WEB application with Django
[Streamlit] I hate JavaScript, so I make a web application only with Python
[Easy detonation velocity] Create a web application in minutes with Streamlit without the need for HTML files
Data acquisition from analytics API with Google API Client for python Part 2 Web application
[Raspberry Pi] Publish a web application on https using Apache + WSGI + Python Flask
Folium: Visualize data on a map with Python
A memorandum for touching python Flask on heroku
Extract data from a web page with Python
Data analysis for improving POG 1 ~ Web scraping with Python ~
Looking back on creating a web service with Django 1
Launch a Python web application with Nginx + Gunicorn with Docker
Looking back on creating a web service with Django 2
Visualize data with Streamlit
How to deploy a web app made with Flask to Heroku
Create a web application that recognizes numbers with a neural network
A network diagram was created with the data of COVID-19.
Dockerfile for creating a data science environment based on pip3
Deploy the strongest front-end Streamlit for data scientists on Azure!
(For beginners) Try creating a simple web API with Django
Deploy a Django application on EC2 with Nginx + Gunicorn + Supervisor
Created a method to downsample for unbalanced data (for binary classification)
Create a Python3.4 + Nginx + uWSGI + Flask Web application execution environment with haste using pyenv on Ubuntu 12.04
Sample data created with python
Web application development with Flask
Web application creation with Django
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
If you know Python, you can make a web application with Django
Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
How to deploy a web application on Alibaba Cloud as a freelancer
Create a USB boot Ubuntu with a Python environment for data analysis