Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,9 +17,9 @@ client = gspread.authorize(creds)
|
|
| 17 |
sheet = client.open("generation_streamlit_0302").sheet1
|
| 18 |
|
| 19 |
# ์ฌ์ฉ์ ์กฐ์ธ ๋ฐ์ดํฐ๋ฅผ Google Sheets ๋ฌธ์์ ์ถ๊ฐํ๋ ํจ์
|
| 20 |
-
def record_advice(concern, advice):
|
| 21 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 22 |
-
sheet.append_row([timestamp, concern, advice])
|
| 23 |
|
| 24 |
# ์คํ์ผ๋ง์ ์ํ CSS
|
| 25 |
st.markdown("""
|
|
@@ -46,30 +46,40 @@ st.markdown('<div class="header">๐ ๋ค๋ฅธ ํ์ฅ ๊ณ ๋ฏผํด๊ฒฐ ๋์์ฃผ๊ธฐ
|
|
| 46 |
|
| 47 |
# Load Excel file into DataFrame
|
| 48 |
df = pd.read_excel("painpoint2.xlsx")
|
| 49 |
-
|
| 50 |
-
|
| 51 |
experience_levels = ['์ ์ฐ์ฐจ ํ์ฅ', '์ค๊ฐ์ฐ์ฐจ ํ์ฅ', '๊ณ ์ฐ์ฐจ ํ์ฅ']
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# ๋ฒํผ ์์ฑ ๋ฐ ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
| 55 |
-
for
|
| 56 |
-
|
| 57 |
-
if
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
st.session_state['
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
# ์กฐ์ธ ์ ์ถ ์น์
|
| 66 |
-
if 'selected_concern' in st.session_state:
|
| 67 |
-
st.subheader(f"{st.session_state['
|
| 68 |
advice = st.text_area("์กฐ์ธ:", height=100)
|
| 69 |
if st.button("์กฐ์ธ ์ ์ถํ๊ธฐ"):
|
| 70 |
if advice.strip(): # ์กฐ์ธ์ด ๋น์ด์์ง ์์ ๊ฒฝ์ฐ
|
| 71 |
-
record_advice(st.session_state['selected_concern'], advice.strip())
|
| 72 |
st.success("์กฐ์ธ์ด ์ฑ๊ณต์ ์ผ๋ก ์ ์ถ๋์์ต๋๋ค!")
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
else:
|
| 75 |
st.error("์กฐ์ธ์ ์
๋ ฅํด์ฃผ์ธ์.")
|
|
|
|
| 17 |
sheet = client.open("generation_streamlit_0302").sheet1
|
| 18 |
|
| 19 |
# ์ฌ์ฉ์ ์กฐ์ธ ๋ฐ์ดํฐ๋ฅผ Google Sheets ๋ฌธ์์ ์ถ๊ฐํ๋ ํจ์
|
| 20 |
+
def record_advice(experience, concern, advice):
|
| 21 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 22 |
+
sheet.append_row([timestamp, experience, concern, advice])
|
| 23 |
|
| 24 |
# ์คํ์ผ๋ง์ ์ํ CSS
|
| 25 |
st.markdown("""
|
|
|
|
| 46 |
|
| 47 |
# Load Excel file into DataFrame
|
| 48 |
df = pd.read_excel("painpoint2.xlsx")
|
| 49 |
+
# ๋ฒํผ์ ๊ฐ๋ก๋ก ๋์ดํ๊ธฐ ์ํ ์ปจํ
์ด๋
|
| 50 |
+
buttons = st.columns(3)
|
| 51 |
experience_levels = ['์ ์ฐ์ฐจ ํ์ฅ', '์ค๊ฐ์ฐ์ฐจ ํ์ฅ', '๊ณ ์ฐ์ฐจ ํ์ฅ']
|
| 52 |
+
button_state = {"active": None} # ์ด๋ค ๋ฒํผ์ด ํ์ฑํ๋์๋์ง ์ถ์
|
| 53 |
+
|
| 54 |
+
# ์ธ์
์ํ ์ด๊ธฐํ
|
| 55 |
+
if 'active_button' not in st.session_state:
|
| 56 |
+
st.session_state['active_button'] = None
|
| 57 |
|
| 58 |
# ๋ฒํผ ์์ฑ ๋ฐ ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
| 59 |
+
for i, experience_level in enumerate(experience_levels):
|
| 60 |
+
with buttons[i]:
|
| 61 |
+
if st.session_state['active_button'] == experience_level:
|
| 62 |
+
st.button(experience_level, disabled=True) # ํ์ฑํ๋ ๋ฒํผ ๋นํ์ฑํ ํ์
|
| 63 |
+
elif st.button(experience_level):
|
| 64 |
+
st.session_state['active_button'] = experience_level # ์ ํ๋ ๋ฒํผ ์ ์ฅ
|
| 65 |
+
concerns = df[experience_level].dropna()
|
| 66 |
+
if not concerns.empty:
|
| 67 |
+
selected_concern = concerns.sample(n=1).iloc[0]
|
| 68 |
+
st.session_state['selected_concern'] = selected_concern
|
| 69 |
+
st.markdown(f"### ์ ํ๋ ๊ณ ๋ฏผ: {selected_concern}")
|
| 70 |
+
else:
|
| 71 |
+
st.error(f"{experience_level}์ ํด๋นํ๋ ๊ณ ๋ฏผ์ด ์์ต๋๋ค.")
|
| 72 |
|
| 73 |
# ์กฐ์ธ ์ ์ถ ์น์
|
| 74 |
+
if 'selected_concern' in st.session_state and st.session_state['active_button']:
|
| 75 |
+
st.subheader(f"{st.session_state['active_button']}์ ๊ณ ๋ฏผ์ ๋ํ ์กฐ์ธ์ ์์ฑํด์ฃผ์ธ์.")
|
| 76 |
advice = st.text_area("์กฐ์ธ:", height=100)
|
| 77 |
if st.button("์กฐ์ธ ์ ์ถํ๊ธฐ"):
|
| 78 |
if advice.strip(): # ์กฐ์ธ์ด ๋น์ด์์ง ์์ ๊ฒฝ์ฐ
|
| 79 |
+
record_advice(st.session_state['active_button'], st.session_state['selected_concern'], advice.strip())
|
| 80 |
st.success("์กฐ์ธ์ด ์ฑ๊ณต์ ์ผ๋ก ์ ์ถ๋์์ต๋๋ค!")
|
| 81 |
+
# ์ ์ถ ํ ์ธ์
์ํ ์ด๊ธฐํ
|
| 82 |
+
st.session_state['selected_concern'] = None
|
| 83 |
+
st.session_state['active_button'] = None
|
| 84 |
else:
|
| 85 |
st.error("์กฐ์ธ์ ์
๋ ฅํด์ฃผ์ธ์.")
|