import streamlit as st from urllib.parse import quote import requests import os API_URL = "http://api:8888/upload" # FastAPI 서비스 이름 기준 DOWNLOAD_URL = "http://172.16.10.176:8888/download/" st.set_page_config(page_title="HANMAC PGN Documents", layout="centered") st.image("/app/app/static/logo.png", use_container_width=True) st.markdown( "

🔹PM Oversea DEMO🔹

", unsafe_allow_html=True ) uploaded_files = st.file_uploader("PDF 파일 업로드", type=["pdf"], accept_multiple_files=True) if st.button("업로드 및 처리") and uploaded_files: files = [("files", (f.name, f.getvalue(), "application/pdf")) for f in uploaded_files] with st.spinner("서버에 업로드 및 처리 중..."): response = requests.post(API_URL, files=files) if response.status_code == 200: st.success("처리 완료! 결과를 아래에서 확인하세요.") results = response.json()["results"] for r in results: filename = r["filename"] json_path = r["saved_path"] encoded_filename = quote(os.path.basename(json_path)) download_link = f"{DOWNLOAD_URL}{encoded_filename}" st.markdown(f"✅ **{filename}** 처리 완료\n[JSON 다운로드]({download_link})") else: st.error("❌ 처리 중 오류가 발생했습니다.")