최초 업로드
This commit is contained in:
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
FROM python:3.9-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
software-properties-common \
|
||||||
|
git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY ./app/ .
|
||||||
|
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 8501
|
||||||
|
|
||||||
|
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
||||||
|
|
||||||
|
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
||||||
63
app/app.py
Normal file
63
app/app.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import streamlit as st
|
||||||
|
import pandas as pd
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
import git
|
||||||
|
import json
|
||||||
|
|
||||||
|
token = os.environ['GIT_TOKEN']
|
||||||
|
# 사용자 목록
|
||||||
|
user = ['변정훈1', '변정훈2', '변정훈3']
|
||||||
|
|
||||||
|
repo_url = f'https://sa_8001:{token}@lab.jhcloud.kr/sa_8001/test_json.git'
|
||||||
|
local_path = 'repo'
|
||||||
|
|
||||||
|
# JSON 데이터 가져오기
|
||||||
|
if os.path.exists(local_path):
|
||||||
|
repo = git.Repo(local_path)
|
||||||
|
repo.remote().pull()
|
||||||
|
else:
|
||||||
|
repo = git.Repo.clone_from(repo_url, local_path)
|
||||||
|
|
||||||
|
json_file_path = os.path.join(local_path, 'test_json.json')
|
||||||
|
|
||||||
|
with open(json_file_path, 'r', encoding='utf-8') as file:
|
||||||
|
data = json.load(file)
|
||||||
|
|
||||||
|
# response = requests.get(json_url)
|
||||||
|
# data = response.json()
|
||||||
|
|
||||||
|
# DataFrame으로 변환
|
||||||
|
df = pd.DataFrame(data)
|
||||||
|
|
||||||
|
# 테이블로 표시
|
||||||
|
st.title('버전 관리')
|
||||||
|
cols = st.columns([5,5])
|
||||||
|
|
||||||
|
edited_df = cols[0].data_editor(df,
|
||||||
|
key="version_table",
|
||||||
|
hide_index=True,
|
||||||
|
column_config={
|
||||||
|
'name': st.column_config.TextColumn(label='이름', disabled=True),
|
||||||
|
'version': st.column_config.TextColumn(label='버전', disabled=False),
|
||||||
|
'user': st.column_config.SelectboxColumn(label='사용자', options=user, required=True),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
cols[1].write(st.session_state["version_table"]["edited_rows"])
|
||||||
|
|
||||||
|
button_cols = st.columns([1, 1])
|
||||||
|
|
||||||
|
with button_cols[0]:
|
||||||
|
if st.button('새로고침'):
|
||||||
|
repo = git.Repo(local_path)
|
||||||
|
repo.remote().pull()
|
||||||
|
st.success("새로고침 완료")
|
||||||
|
|
||||||
|
with button_cols[1]:
|
||||||
|
if st.button('업데이트'):
|
||||||
|
edited_df.to_json(json_file_path, orient='records', indent=4)
|
||||||
|
repo.index.add(["/app/"+json_file_path])
|
||||||
|
repo.index.commit("버전 업데이트")
|
||||||
|
repo.remote().push()
|
||||||
|
st.success("업데이트 완료")
|
||||||
4
app/requirements.txt
Normal file
4
app/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
streamlit
|
||||||
|
pandas
|
||||||
|
requests
|
||||||
|
gitpython
|
||||||
Reference in New Issue
Block a user