Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -55,7 +55,7 @@ def questionnaire():
|
|
55 |
margin-top: 8px !important;
|
56 |
}
|
57 |
.question-text {
|
58 |
-
font-size:
|
59 |
font-weight: bold;
|
60 |
margin-bottom: 20px;
|
61 |
}
|
@@ -64,7 +64,13 @@ def questionnaire():
|
|
64 |
"""
|
65 |
st.markdown(custom_css, unsafe_allow_html=True)
|
66 |
|
67 |
-
st.title("
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
# 使用session_state来跟踪当前的问题索引
|
@@ -87,13 +93,13 @@ def questionnaire():
|
|
87 |
|
88 |
option_a, option_b = OPTIONS[current_question]
|
89 |
cols[0].markdown('<div class="custom-radio">', unsafe_allow_html=True)
|
90 |
-
selected_option = cols[0].radio("", [option_a, option_b, "
|
91 |
cols[0].markdown('</div>', unsafe_allow_html=True)
|
92 |
|
93 |
user_answer = None
|
94 |
with st.container():
|
95 |
st.markdown("---")
|
96 |
-
if selected_option == "
|
97 |
# 使用.get()方法获取值,并在键不存在时提供一个默认值
|
98 |
default_value = st.session_state.answers_other.get(st.session_state.current_question_index, "")
|
99 |
user_answer = st.text_input("Please write your answer:", default_value)
|
@@ -110,7 +116,7 @@ def questionnaire():
|
|
110 |
# 首个问题
|
111 |
elif st.session_state.current_question_index == 0:
|
112 |
if st.button("Next"):
|
113 |
-
if selected_option == "
|
114 |
st.session_state.answers_other[current_question] = user_answer
|
115 |
else:
|
116 |
st.session_state.answers_choices[current_question] = user_answer
|
@@ -126,7 +132,7 @@ def questionnaire():
|
|
126 |
st.session_state.current_question_index -= 1
|
127 |
st.experimental_rerun()
|
128 |
elif submit_button.button("Submit"):
|
129 |
-
if selected_option == "
|
130 |
st.session_state.answers_other[current_question] = user_answer
|
131 |
|
132 |
else:
|
@@ -162,7 +168,12 @@ def questionnaire():
|
|
162 |
|
163 |
def post():
|
164 |
# 设置页面标题
|
165 |
-
st.title("
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
# 创建文本输入框
|
168 |
user_input = st.text_area("Enter your post here:")
|
|
|
55 |
margin-top: 8px !important;
|
56 |
}
|
57 |
.question-text {
|
58 |
+
font-size: 30px;
|
59 |
font-weight: bold;
|
60 |
margin-bottom: 20px;
|
61 |
}
|
|
|
64 |
"""
|
65 |
st.markdown(custom_css, unsafe_allow_html=True)
|
66 |
|
67 |
+
st.title("MBTI Personality Insight")
|
68 |
+
st.markdown("""
|
69 |
+
<p style='font-size:20px'>
|
70 |
+
Discover deeper insights about your Myers-Briggs Type Indicator (MBTI) personality through this interactive questionnaire.
|
71 |
+
If the options couldn't describe you, customize your answers.
|
72 |
+
</p>
|
73 |
+
""", unsafe_allow_html=True)
|
74 |
|
75 |
|
76 |
# 使用session_state来跟踪当前的问题索引
|
|
|
93 |
|
94 |
option_a, option_b = OPTIONS[current_question]
|
95 |
cols[0].markdown('<div class="custom-radio">', unsafe_allow_html=True)
|
96 |
+
selected_option = cols[0].radio("", [option_a, option_b, "Not Listed? Enter Your Own"])
|
97 |
cols[0].markdown('</div>', unsafe_allow_html=True)
|
98 |
|
99 |
user_answer = None
|
100 |
with st.container():
|
101 |
st.markdown("---")
|
102 |
+
if selected_option == "Not Listed? Enter Your Own":
|
103 |
# 使用.get()方法获取值,并在键不存在时提供一个默认值
|
104 |
default_value = st.session_state.answers_other.get(st.session_state.current_question_index, "")
|
105 |
user_answer = st.text_input("Please write your answer:", default_value)
|
|
|
116 |
# 首个问题
|
117 |
elif st.session_state.current_question_index == 0:
|
118 |
if st.button("Next"):
|
119 |
+
if selected_option == "Not Listed? Enter Your Own":
|
120 |
st.session_state.answers_other[current_question] = user_answer
|
121 |
else:
|
122 |
st.session_state.answers_choices[current_question] = user_answer
|
|
|
132 |
st.session_state.current_question_index -= 1
|
133 |
st.experimental_rerun()
|
134 |
elif submit_button.button("Submit"):
|
135 |
+
if selected_option == "Not Listed? Enter Your Own":
|
136 |
st.session_state.answers_other[current_question] = user_answer
|
137 |
|
138 |
else:
|
|
|
168 |
|
169 |
def post():
|
170 |
# 设置页面标题
|
171 |
+
st.title("MBTI Personality Insight")
|
172 |
+
st.markdown("""
|
173 |
+
<p style='font-size:20px'>
|
174 |
+
Upload posts to get insights about MBTI personality analysis.
|
175 |
+
</p>
|
176 |
+
""", unsafe_allow_html=True)
|
177 |
|
178 |
# 创建文本输入框
|
179 |
user_input = st.text_area("Enter your post here:")
|