Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,6 +21,7 @@ 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 |
st.markdown("""
|
| 25 |
<style>
|
| 26 |
.header {
|
|
@@ -40,73 +41,40 @@ st.markdown("""
|
|
| 40 |
</style>
|
| 41 |
""", unsafe_allow_html=True)
|
| 42 |
|
| 43 |
-
#
|
| 44 |
st.markdown('<div class="header">๐ ๋ค๋ฅธ ํ์ฅ ๊ณ ๋ฏผํด๊ฒฐ ๋์์ฃผ๊ธฐ ๐ </div>', unsafe_allow_html=True)
|
| 45 |
|
| 46 |
-
st.markdown("""
|
| 47 |
-
<div class="description-box">
|
| 48 |
-
<p> How to use </br> 1. ์ข์ธก์์ ์กฐ์ธ์ ์ ๊ณตํ ํ์ฅ์ ์ฐ์ฐจ๋ฅผ ์ ํํด์ฃผ์ธ์. </br> 2. [๊ณ ๋ฏผ ํ์ธ]๋ฒํผ์ ๋๋ฅด๋ฉด ์๋์ ๊ณ ๋ฏผ ๋ด์ฉ๊ณผ ์กฐ์ธ ์์ฑ์ฐฝ์ด ๋น๋๋ค. </br> 3. ๋ค์ ํ๋ฒ [๊ณ ๋ฏผ ํ์ธ]๋ฒํผ์ ๋๋ฅด๋ฉด ์๋ก์ด ๊ณ ๋ฏผ์ด ๋์ต๋๋ค </br> </p>
|
| 49 |
-
</div>
|
| 50 |
-
""", unsafe_allow_html=True)
|
| 51 |
-
|
| 52 |
# Load Excel file into DataFrame
|
| 53 |
df = pd.read_excel("painpoint2.xlsx")
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
#
|
| 75 |
-
st.
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
if
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
st.session_state['button_clicked'] = True
|
| 85 |
-
|
| 86 |
-
# Display random rows based on selected experience level
|
| 87 |
-
if submit_button_left:
|
| 88 |
-
st.subheader("์ ํ๋ ๊ณ ๋ฏผ์?")
|
| 89 |
-
selected_row = df[selected_experience].sample(n=1).iloc[0]
|
| 90 |
-
st.session_state['selected_concern'] = selected_row['๊ณ ๋ฏผ'] # ์ฌ๊ธฐ์ '๊ณ ๋ฏผ'์ DataFrame์ ํด๋น ์ด ์ด๋ฆ์
๋๋ค.
|
| 91 |
-
with st.expander("๊ณ ๋ฏผ ๋ด์ฉ๋ณด๊ธฐ", expanded=True):
|
| 92 |
-
st.markdown(selected_row['๊ณ ๋ฏผ']) # ์ธ์
์ํ์ ์ ์ฅ๋ ๊ณ ๋ฏผ ๋ด์ฉ์ ์ฌ์ฉ์์๊ฒ ๋ณด์ฌ์ค๋๋ค.
|
| 93 |
-
|
| 94 |
-
# Add advice section
|
| 95 |
-
st.subheader("๊ณ ๋ฏผ ์กฐ์ธํด์ฃผ๊ธฐ")
|
| 96 |
-
st.write("๋ค๋ฅธ ํ์ฅ๋๋ค์ ๊ณ ๋ฏผ์ ๋ํด ์กฐ์ธํด์ฃผ์๊ฒ ์ด์?")
|
| 97 |
-
advice = st.text_area(" ", height=100)
|
| 98 |
-
submit_button_right = st.button("์กฐ์ธ ์ ์ถํ๊ธฐ")
|
| 99 |
-
|
| 100 |
-
# ์กฐ์ธ ์ ์ถ ๋ฒํผ ์ฒ๋ฆฌ
|
| 101 |
-
if submit_button_right:
|
| 102 |
-
if not st.session_state.get('submitted', False): # 'submitted' ์ํ๊ฐ False์ธ ๊ฒฝ์ฐ์๋ง ์คํ
|
| 103 |
-
user_advice = advice.strip() # ์ฌ์ฉ์ ์
๋ ฅ์์ ๊ณต๋ฐฑ ์ ๊ฑฐ
|
| 104 |
-
if user_advice: # ์ฌ์ฉ์๊ฐ ์ค์ ๋ก ์กฐ์ธ์ ์
๋ ฅํ๋์ง ํ์ธ
|
| 105 |
-
selected_concern = st.session_state.get('selected_concern', '๊ณ ๋ฏผ ์์') # ์ธ์
์ํ์์ ์ ํ๋ ๊ณ ๋ฏผ ๋ด์ฉ์ ๊ฐ์ ธ์ด
|
| 106 |
-
record_advice(selected_concern, user_advice) # Google Sheets์ ๊ธฐ๋ก
|
| 107 |
-
st.session_state['submitted'] = True # 'submitted' ์ํ๋ฅผ True๋ก ์ค์ ํ์ฌ ์ค๋ณต ์ ์ถ ๋ฐฉ์ง
|
| 108 |
-
st.success("์กฐ์ธ์ด ์ฑ๊ณต์ ์ผ๋ก ์ ์ถ๋์์ต๋๋ค!")
|
| 109 |
-
else:
|
| 110 |
-
st.error("์กฐ์ธ์ ์
๋ ฅํด์ฃผ์ธ์.") # ์ฌ์ฉ์๊ฐ ์กฐ์ธ์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ ์๋ฌ ๋ฉ์์ง ์ถ๋ ฅ
|
| 111 |
else:
|
| 112 |
-
st.
|
|
|
|
| 21 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 22 |
sheet.append_row([timestamp, concern, advice])
|
| 23 |
|
| 24 |
+
# ์คํ์ผ๋ง์ ์ํ CSS
|
| 25 |
st.markdown("""
|
| 26 |
<style>
|
| 27 |
.header {
|
|
|
|
| 41 |
</style>
|
| 42 |
""", unsafe_allow_html=True)
|
| 43 |
|
| 44 |
+
# ํค๋ ํ์
|
| 45 |
st.markdown('<div class="header">๐ ๋ค๋ฅธ ํ์ฅ ๊ณ ๋ฏผํด๊ฒฐ ๋์์ฃผ๊ธฐ ๐ </div>', unsafe_allow_html=True)
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
# Load Excel file into DataFrame
|
| 48 |
df = pd.read_excel("painpoint2.xlsx")
|
| 49 |
|
| 50 |
+
# Add radio button to select experience level and display concerns
|
| 51 |
+
experience_levels = ['์ ์ฐ์ฐจ ํ์ฅ', '์ค๊ฐ์ฐ์ฐจ ํ์ฅ', '๊ณ ์ฐ์ฐจ ํ์ฅ']
|
| 52 |
+
selected_experience = st.radio("์กฐ์ธํด์ค ์ฐ์ฐจ ์ ํํ๊ธฐ:", experience_levels)
|
| 53 |
+
submit_button = st.button(f"{selected_experience} ๊ณ ๋ฏผ ํ์ธ")
|
| 54 |
+
|
| 55 |
+
# Display random concern based on selected experience level
|
| 56 |
+
if submit_button:
|
| 57 |
+
if selected_experience in df.columns:
|
| 58 |
+
# ํด๋น ์ฐ์ฐจ ์ด์์ ๋ฌด์์๋ก ๊ณ ๋ฏผ์ ์ ํ
|
| 59 |
+
concerns = df[selected_experience].dropna()
|
| 60 |
+
if not concerns.empty:
|
| 61 |
+
selected_concern = concerns.sample(n=1).iloc[0]
|
| 62 |
+
st.session_state['selected_concern'] = selected_concern
|
| 63 |
+
st.markdown(f"### ์ ํ๋ ๊ณ ๋ฏผ: {selected_concern}")
|
| 64 |
+
else:
|
| 65 |
+
st.error(f"{selected_experience}์ ํด๋นํ๋ ๊ณ ๋ฏผ์ด ์์ต๋๋ค.")
|
| 66 |
+
else:
|
| 67 |
+
st.error("์ ํํ ์ฐ์ฐจ์ ํด๋นํ๋ ์ด์ด ๋ฐ์ดํฐ์ ์์ต๋๋ค.")
|
| 68 |
+
|
| 69 |
+
# ์กฐ์ธ ์ ์ถ ์น์
|
| 70 |
+
if 'selected_concern' in st.session_state:
|
| 71 |
+
advice = st.text_area("๊ณ ๋ฏผ์ ๋ํ ์กฐ์ธ์ ์
๋ ฅํด์ฃผ์ธ์:", height=100)
|
| 72 |
+
submit_advice_button = st.button("์กฐ์ธ ์ ์ถํ๊ธฐ")
|
| 73 |
+
|
| 74 |
+
if submit_advice_button:
|
| 75 |
+
if advice.strip(): # ์กฐ์ธ์ด ๋น์ด์์ง ์์ ๊ฒฝ์ฐ
|
| 76 |
+
record_advice(st.session_state['selected_concern'], advice.strip())
|
| 77 |
+
st.success("์กฐ์ธ์ด ์ฑ๊ณต์ ์ผ๋ก ์ ์ถ๋์์ต๋๋ค!")
|
| 78 |
+
del st.session_state['selected_concern'] # ์ ์ถ ํ ์ ํ๋ ๊ณ ๋ฏผ ์ด๊ธฐํ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
else:
|
| 80 |
+
st.error("์กฐ์ธ์ ์
๋ ฅํด์ฃผ์ธ์.")
|