FormingStar / app.py
Antonio0616's picture
Update app.py
d08e094 verified
import streamlit as st
from pathlib import Path
import base64
from dashboard_theme.theme import inject
st.set_page_config(page_title="FormingStar", layout="wide")
inject("graphite_gold")
PASSWORD = "ajin2025"
# -------------------------------
# ์„ธ์…˜ ์ดˆ๊ธฐํ™”
# -------------------------------
if "authenticated" not in st.session_state:
st.session_state["authenticated"] = False
# -------------------------------
# ๋กœ๊ทธ์ธ ํ™”๋ฉด
# -------------------------------
if not st.session_state["authenticated"]:
st.title("๐Ÿ”’ FormingStar ์ ‘์† ์ธ์ฆ")
pwd = st.text_input("๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”", type="password")
if st.button("์ ‘์†ํ•˜๊ธฐ"):
if pwd == PASSWORD:
st.session_state["authenticated"] = True
st.success("โœ… ์ธ์ฆ ์„ฑ๊ณต! ์ด์ œ ์ƒ๋‹จ ํƒญ์—์„œ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์œผ๋กœ ์ด๋™ํ•˜์„ธ์š”.")
st.rerun()
else:
st.error("โŒ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค.")
# -------------------------------
# ์ธ์ฆ ํ›„ ๋ฉ”์ธ ํ™”๋ฉด
# -------------------------------
else:
# -------------------------------
# CSS (Home.py์™€ ๋™์ผ)
# -------------------------------
st.markdown(
"""
<style>
.block-container { padding-top: 1.25rem !important; }
.logo-wrap { display:flex; justify-content:center; margin: 6px 0 10px; }
.logo-wrap img { width: clamp(160px, 24vw, 320px); height: auto; }
h2.hero-title {
margin: 4px 0 6px !important;
text-align:center; color: var(--text);
font-size: clamp(22px, 3vw, 36px);
line-height: 1.12;
}
p.hero-sub {
margin: 2px 0 8px !important;
text-align:center; color: var(--muted);
}
hr.hr-thin {
border: 0; border-top: 1px solid var(--border);
margin: 10px 0 !important;
}
.notice {
background-color:#2A2F3A; color:#E0E6ED;
padding:10px 16px; border-radius:10px; text-align:center;
max-width:640px; margin: 8px auto 0;
font-weight:600; border:1px solid var(--border);
box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
</style>
""",
unsafe_allow_html=True
)
# -------------------------------
# ๐Ÿ”ธ ํšŒ์‚ฌ ๋กœ๊ณ 
# -------------------------------
def find_logo():
here = Path(__file__).parent
for p in [
here / "formingstar.png",
here / "assets" / "formingstar.png",
Path.cwd() / "formingstar.png"
]:
if p.exists():
return p
return None
logo_path = find_logo()
if logo_path:
logo_b64 = base64.b64encode(logo_path.read_bytes()).decode()
st.markdown(
f'<div class="logo-wrap"><img src="data:image/png;base64,{logo_b64}" alt="FORMINGSTAR Logo"></div>',
unsafe_allow_html=True
)
else:
st.warning("๋กœ๊ณ  ํŒŒ์ผ(formingstar.png)์„ ์ฐพ์ง€ ๋ชปํ–ˆ์–ด์š”. Home.py์™€ ๊ฐ™์€ ํด๋” ๋˜๋Š” /assets ํด๋”์— ์žˆ๋Š”์ง€ ํ™•์ธํ•ด ์ฃผ์„ธ์š”.")
# -------------------------------
# ๐Ÿ”ธ ๋ฉ”์ธ ํƒ€์ดํ‹€ & ์„ค๋ช…
# -------------------------------
st.markdown('<h2 class="hero-title">AIโˆ™๋น…๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ์„ฑํ˜•์„ฑ ์˜ˆ์ธก ๋ชจ๋ธ</h2>', unsafe_allow_html=True)
st.markdown('<p class="hero-sub">์ž๋™์ฐจ ์ฐจ์ฒด ๊ธˆํ˜• ํ•ด์„ ๊ณผ์ •์„ ์‰ฝ๊ฒŒ ๋ฐฐ์šฐ๊ณ  ์‹ค์Šตํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ€์ด๋“œ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค.</p>', unsafe_allow_html=True)
st.markdown('<hr class="hr-thin">', unsafe_allow_html=True)
# -------------------------------
# ๐Ÿ”ธ ๋ฒ„ํŠผ โ†’ ํŽ˜์ด์ง€ ์ด๋™
# -------------------------------
left, mid, right = st.columns([1, 1.2, 1])
with mid:
if st.button("์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹œ์ž‘ํ•˜๊ธฐ", use_container_width=True):
st.switch_page("pages/1_Simulation.py")
st.markdown('<hr class="hr-thin">', unsafe_allow_html=True)
# -------------------------------
# ๐Ÿ”ธ ์•ˆ๋‚ด ๋ฌธ๊ตฌ
# -------------------------------
st.markdown(
'<div class="notice">์ขŒ์ธก ์‚ฌ์ด๋“œ๋ฐ”์—์„œ๋„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๋ฉ”๋‰ด๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.</div>',
unsafe_allow_html=True
)