7.1 Streamlit Community Cloud

Streamlit 이란 프레임워크는 분석한 데이터를 대시보드 형태와 같이 웹으로 구현하는 유용한 도구입니다. 하지만 분석 결과가 다른 사람들과 공유되지 않는다면 그 가치는 제한됩니다. Streamlit은 이를 고려하여 다양한 공유 기능을 제공하고 있습니다.

Python 애플리케이션을 배포하는 방법은 여러 가지가 있지만, Streamlit은 Streamlit Community Cloud 서비스를 통해 데이터 분석 결과를 웹 형태로 손쉽게 구현하고 배포할 수 있는 기능을 제공합니다.

Cloud • Streamlit

<aside> 💡 Streamlit Community Cloud

Streamlit에서 제공하는 서비스를 통한 애플리케이션 배포는 크게 5 단계로 진행됩니다.

  1. Streamlit app 구현 및 코드 작성
  2. Streamlit Community Cloud 계정 생성
  3. Streamlit Community Cloud 계정과 Github 계정 연동 (Github 계정이 없을 시, Github 계정 생성 후 연동)
  4. Github Repository 생성 및 애플리케이션 업로드
  5. Streamlit Community Cloud를 이용하여 배포

7.2 Streamlit 애플리케이션 구현

배포하기 위한 애플리케이션을 구현합니다. 코드 파일의 확장자가 “.py”이어야 합니다.

from datetime import datetime
from tqdm import tqdm
import streamlit as st
import time
import pandas as pd

st.title("Streamlit Deploy Test")

st.markdown(
"""
Hello Likelions,

This is a demo of Streamlit deployment.

""")

name = st.text_input("What's your name?", "Lion")

date = st.date_input("Choose a date", datetime.now().date())

st.markdown(f"## Hello {name}!\\n## The date is {date.strftime('%Y-%m-%d')}")

st.subheader("A cached dataframe")

@st.cache_data()
def get_data(date):
    for i in tqdm(range(10)):
        time.sleep(0.1)
    return pd.DataFrame({"date": pd.date_range(date, periods=3), 
                         "c": [7, 8, 5], "d": [10, 11, 7]}).set_index("date")

df = get_data(date)
st.write(df)

7.3 Streamlit Community Cloud 계정 생성 및 Github 연동

Streamlit Community Cloud 계정 생성

Cloud • Streamlit

Streamlit Community Cloud은 기존의 Google 계정과 Github 계정으로 가입을 할 수 있습니다. Google 및 Github 이외의 E-mail 계정으로 가입 진행 시, E-mail 인증 완료 후 이용 가능합니다.