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("업데이트 완료")