Spaces:
Sleeping
Sleeping
File size: 2,428 Bytes
23c4494 bab2bc2 23c4494 bab2bc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
import streamlit as st
import random
from streamlit_extras.switch_page_button import switch_page
# ๋ก๊ทธ์ธ ์ํ ๊ด๋ฆฌ
if 'logged_in' not in st.session_state:
st.session_state.logged_in = False
# ๋ก๊ทธ์ธ ํ์ด์ง
def login_page():
st.title("๋ก๊ทธ์ธ ํ์ด์ง")
st.write("๊ณ์ ์ ๋ณด๋ฅผ ์
๋ ฅํ์ธ์.")
username = st.text_input("์ฌ์ฉ์ ์ด๋ฆ")
password = st.text_input("๋น๋ฐ๋ฒํธ", type="password")
if st.button("๋ก๊ทธ์ธ"):
if username == "admin" and password == "password123": # ๊ฐ๋จํ ๋ก๊ทธ์ธ ๊ฒ์ฆ
st.session_state.logged_in = True
st.success("๋ก๊ทธ์ธ ์ฑ๊ณต!")
switch_page("์ด๋ฆ ์
๋ ฅ")
else:
st.error("๋ก๊ทธ์ธ ์คํจ! ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ๋น๋ฐ๋ฒํธ๊ฐ ์๋ชป๋์์ต๋๋ค.")
# ์ด๋ฆ ์
๋ ฅ ํ์ด์ง
def name_input_page():
st.title("์ด๋ฆ ์
๋ ฅ ํ์ด์ง")
st.write("์ด๋ฆ์ ํ ์ค์ ํ๋์ฉ ์
๋ ฅํ์ธ์.")
names_input = st.text_area("์ด๋ฆ ๋ชฉ๋ก", height=200)
if st.button("๋งค์นญ ์์ํ๊ธฐ"):
names = [name.strip() for name in names_input.strip().split('\n') if name.strip()]
if len(names) < 2:
st.error("๋งค์นญํ ์ด๋ฆ์ด 2๊ฐ ์ด์ ํ์ํฉ๋๋ค.")
else:
st.session_state.names = names
switch_page("๋งค์นญ ๊ฒฐ๊ณผ")
# ๋งค์นญ ๊ฒฐ๊ณผ ํ์ด์ง
def match_page():
st.title("๋งค์นญ ๊ฒฐ๊ณผ ํ์ด์ง")
if 'names' not in st.session_state or not st.session_state.names:
st.warning("์ด๋ฆ ์
๋ ฅ ํ์ด์ง์์ ์ด๋ฆ์ ๋จผ์ ์
๋ ฅํ์ธ์!")
return
names = st.session_state.names
random.shuffle(names)
mid = len(names) // 2
group_A = names[:mid]
group_B = names[mid:]
matching_pairs = [(a, b) for a, b in zip(group_A, group_B)]
st.subheader("๋งค์นญ ๊ฒฐ๊ณผ:")
for pair in matching_pairs:
st.write(f"{pair[0]} - {pair[1]}")
unmatched = set(names) - set(a for a, _ in matching_pairs) - set(b for _, b in matching_pairs)
if unmatched:
st.write("๋งค์นญ๋์ง ์์ ์ฌ๋:")
for name in unmatched:
st.write(name)
# ํ์ด์ง ๋ก์ง ์ค์
if st.session_state.logged_in:
if st.sidebar.radio("ํ์ด์ง ์ ํ", ["์ด๋ฆ ์
๋ ฅ", "๋งค์นญ ๊ฒฐ๊ณผ"]) == "์ด๋ฆ ์
๋ ฅ":
name_input_page()
else:
match_page()
else:
login_page()
|