Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ st.set_page_config(page_title="๊ณ ๋ฏผ ํด๊ฒฐ์ฌ", page_icon=":sunglasses:")
|
|
| 10 |
# Google Sheets ์ธ์ฆ ์ค์
|
| 11 |
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/spreadsheets",
|
| 12 |
"https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
|
| 13 |
-
creds = ServiceAccountCredentials.from_json_keyfile_name("analog-marking-416002-e369840763fa.json", scope)
|
| 14 |
client = gspread.authorize(creds)
|
| 15 |
|
| 16 |
# Google Sheets ๋ฌธ์ ์ด๊ธฐ
|
|
@@ -21,19 +21,18 @@ 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("""
|
| 26 |
<style>
|
| 27 |
.header {
|
| 28 |
font-size: 30px;
|
| 29 |
font-weight: bold;
|
| 30 |
margin-bottom: 20px;
|
| 31 |
-
color: #333;
|
| 32 |
padding: 10px;
|
| 33 |
border-radius: 10px;
|
| 34 |
}
|
| 35 |
.description-box {
|
| 36 |
-
background-color: #f0f0f0;
|
| 37 |
padding: 10px;
|
| 38 |
border-radius: 10px;
|
| 39 |
margin-bottom: 10px;
|
|
@@ -41,48 +40,73 @@ st.markdown("""
|
|
| 41 |
</style>
|
| 42 |
""", unsafe_allow_html=True)
|
| 43 |
|
| 44 |
-
#
|
| 45 |
st.markdown('<div class="header">๐ ๋ค๋ฅธ ํ์ฅ ๊ณ ๋ฏผํด๊ฒฐ ๋์์ฃผ๊ธฐ ๐ </div>', unsafe_allow_html=True)
|
| 46 |
|
| 47 |
-
# ์ค๋ช
ํ์
|
| 48 |
st.markdown("""
|
| 49 |
<div class="description-box">
|
| 50 |
-
<p> How to use </br> 1.
|
| 51 |
</div>
|
| 52 |
""", unsafe_allow_html=True)
|
| 53 |
|
| 54 |
-
# Excel
|
| 55 |
df = pd.read_excel("painpoint2.xlsx")
|
| 56 |
|
| 57 |
-
#
|
| 58 |
seniority_options = ['์ ์ฐ์ฐจ ํ์ฅ', '์ค๊ฐ์ฐ์ฐจ ํ์ฅ', '๊ณ ์ฐ์ฐจ ํ์ฅ']
|
| 59 |
|
| 60 |
-
|
| 61 |
-
st.
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
submit_button_left = st.button("๊ณ ๋ฏผ ํ์ธ")
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
if submit_button_left:
|
| 69 |
st.subheader("์ ํ๋ ๊ณ ๋ฏผ์?")
|
| 70 |
-
selected_row = df[
|
| 71 |
-
st.session_state['selected_concern'] = selected_row['๊ณ ๋ฏผ']
|
| 72 |
with st.expander("๊ณ ๋ฏผ ๋ด์ฉ๋ณด๊ธฐ", expanded=True):
|
| 73 |
-
st.markdown(selected_row['๊ณ ๋ฏผ'])
|
| 74 |
|
| 75 |
-
#
|
| 76 |
st.subheader("๊ณ ๋ฏผ ์กฐ์ธํด์ฃผ๊ธฐ")
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
if
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
else:
|
| 88 |
-
st.
|
|
|
|
| 10 |
# Google Sheets ์ธ์ฆ ์ค์
|
| 11 |
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/spreadsheets",
|
| 12 |
"https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
|
| 13 |
+
creds = ServiceAccountCredentials.from_json_keyfile_name("/Users/crystal/generation/analog-marking-416002-e369840763fa.json", scope)
|
| 14 |
client = gspread.authorize(creds)
|
| 15 |
|
| 16 |
# Google Sheets ๋ฌธ์ ์ด๊ธฐ
|
|
|
|
| 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 {
|
| 27 |
font-size: 30px;
|
| 28 |
font-weight: bold;
|
| 29 |
margin-bottom: 20px;
|
| 30 |
+
color: #333; /* Dark gray color */
|
| 31 |
padding: 10px;
|
| 32 |
border-radius: 10px;
|
| 33 |
}
|
| 34 |
.description-box {
|
| 35 |
+
background-color: #f0f0f0; /* Light gray background */
|
| 36 |
padding: 10px;
|
| 37 |
border-radius: 10px;
|
| 38 |
margin-bottom: 10px;
|
|
|
|
| 40 |
</style>
|
| 41 |
""", unsafe_allow_html=True)
|
| 42 |
|
| 43 |
+
# Display the header
|
| 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 |
+
# Define experience level options
|
| 56 |
seniority_options = ['์ ์ฐ์ฐจ ํ์ฅ', '์ค๊ฐ์ฐ์ฐจ ํ์ฅ', '๊ณ ์ฐ์ฐจ ํ์ฅ']
|
| 57 |
|
| 58 |
+
def set_background():
|
| 59 |
+
st.markdown(
|
| 60 |
+
"""
|
| 61 |
+
<style>
|
| 62 |
+
.stApp {
|
| 63 |
+
background-image: url('URL_TO_YOUR_BACKGROUND_IMAGE');
|
| 64 |
+
background-size: cover;
|
| 65 |
+
}
|
| 66 |
+
</style>
|
| 67 |
+
""",
|
| 68 |
+
unsafe_allow_html=True
|
| 69 |
+
)
|
| 70 |
|
| 71 |
+
set_background()
|
|
|
|
| 72 |
|
| 73 |
+
st.sidebar.markdown("#\n" * 5)
|
| 74 |
+
# Add radio button to select experience level
|
| 75 |
+
st.sidebar.subheader("์กฐ์ธํด์ค ์ฐ์ฐจ ์ ํํ๊ธฐ:")
|
| 76 |
+
selected_experience = st.sidebar.radio(" ", seniority_options)
|
| 77 |
+
submit_button_left = st.sidebar.button("๊ณ ๋ฏผ ํ์ธ")
|
| 78 |
+
# Initialize session state for button click
|
| 79 |
+
if 'button_clicked' not in st.session_state:
|
| 80 |
+
st.session_state['button_clicked'] = False
|
| 81 |
+
|
| 82 |
+
# Modify the button click to update session state
|
| 83 |
+
if submit_button_left:
|
| 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.warning("์ด๋ฏธ ์ ์ถ๋์์ต๋๋ค.") # ์ด๋ฏธ ์ ์ถ๋ ๊ฒฝ์ฐ ๊ฒฝ๊ณ ๋ฉ์์ง ์ถ๋ ฅ
|