Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,19 +13,31 @@ responses_file_path = "responses_data.csv"
|
|
13 |
if user_type == "μ€λ¬Έ μ€μ ":
|
14 |
st.title("μ€λ¬Έ μ€μ ")
|
15 |
question = st.text_input("μ€λ¬Έ μ§λ¬Έμ μ
λ ₯νμΈμ:")
|
16 |
-
|
17 |
-
options = [
|
|
|
|
|
|
|
|
|
18 |
if st.button("μ€λ¬Έ μμ"):
|
19 |
-
if question
|
20 |
data = {
|
21 |
'question': [question],
|
22 |
-
'options': [options]
|
|
|
23 |
}
|
24 |
df = pd.DataFrame(data)
|
25 |
df.to_csv(survey_file_path, index=False)
|
26 |
st.success("μ€λ¬Έμ΄ μ€μ λμμ΅λλ€.")
|
27 |
else:
|
28 |
-
st.error("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# νμ μλ΅ νμ΄μ§
|
31 |
elif user_type == "νμ μλ΅":
|
@@ -33,22 +45,25 @@ elif user_type == "νμ μλ΅":
|
|
33 |
if os.path.exists(survey_file_path):
|
34 |
df = pd.read_csv(survey_file_path)
|
35 |
question = df['question'][0]
|
36 |
-
|
37 |
-
options
|
38 |
|
39 |
st.write(f"### {question}")
|
40 |
-
selected_option = st.radio("λ΅λ³μ μ ννμΈμ:", options)
|
41 |
|
42 |
-
if
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
44 |
else:
|
45 |
-
|
46 |
|
47 |
if st.button("λ΅λ³ μ μΆ"):
|
48 |
# μλ΅ λ°μ΄ν° μ μ₯
|
49 |
response_data = {
|
50 |
-
'
|
51 |
-
'μ£Όκ΄μ': [open_answer if selected_option == "κΈ°ν (μ§μ μ
λ ₯)" else ""]
|
52 |
}
|
53 |
response_df = pd.DataFrame(response_data)
|
54 |
|
@@ -58,10 +73,9 @@ elif user_type == "νμ μλ΅":
|
|
58 |
response_df.to_csv(responses_file_path, index=False)
|
59 |
|
60 |
st.success("λ΅λ³μ΄ μ μΆλμμ΅λλ€!")
|
|
|
|
|
61 |
|
62 |
-
# νλ©΄ μ΄κΈ°νλ₯Ό μν λ³μ μ¬μ€μ
|
63 |
-
st.session_state['submitted'] = True
|
64 |
-
st.rerun() # experimental_rerun λμ rerun μ¬μ©
|
65 |
else:
|
66 |
st.warning("μ€λ¬Έμ΄ μμ§ μ€μ λμ§ μμμ΅λλ€. κ΅μ¬μκ² λ¬ΈμνμΈμ.")
|
67 |
|
@@ -70,10 +84,12 @@ elif user_type == "κ²°κ³Ό νμΈ":
|
|
70 |
st.title("μ€λ¬Έ κ²°κ³Ό νμΈ")
|
71 |
if os.path.exists(responses_file_path):
|
72 |
df = pd.read_csv(responses_file_path)
|
73 |
-
st.write("###
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
78 |
else:
|
79 |
st.warning("μμ§ μ μΆλ λ΅λ³μ΄ μμ΅λλ€.")
|
|
|
13 |
if user_type == "μ€λ¬Έ μ€μ ":
|
14 |
st.title("μ€λ¬Έ μ€μ ")
|
15 |
question = st.text_input("μ€λ¬Έ μ§λ¬Έμ μ
λ ₯νμΈμ:")
|
16 |
+
use_options = st.checkbox("κ°κ΄μ μ΅μ
μ¬μ©")
|
17 |
+
options = []
|
18 |
+
if use_options:
|
19 |
+
options = st.text_area("μ νν λ΅λ³ νλͺ©μ μ
λ ₯νμΈμ (κ° νλͺ©μ μ μ€μ μ
λ ₯):").split('\n')
|
20 |
+
options = [option.strip() for option in options if option.strip()] # λΉ μ΅μ
μ κ±°
|
21 |
+
|
22 |
if st.button("μ€λ¬Έ μμ"):
|
23 |
+
if question:
|
24 |
data = {
|
25 |
'question': [question],
|
26 |
+
'options': [options],
|
27 |
+
'use_options': [use_options]
|
28 |
}
|
29 |
df = pd.DataFrame(data)
|
30 |
df.to_csv(survey_file_path, index=False)
|
31 |
st.success("μ€λ¬Έμ΄ μ€μ λμμ΅λλ€.")
|
32 |
else:
|
33 |
+
st.error("μ§λ¬Έμ μ
λ ₯νμΈμ.")
|
34 |
+
|
35 |
+
if st.button("μ€μ μ΄κΈ°ν"):
|
36 |
+
if os.path.exists(survey_file_path):
|
37 |
+
os.remove(survey_file_path)
|
38 |
+
if os.path.exists(responses_file_path):
|
39 |
+
os.remove(responses_file_path)
|
40 |
+
st.success("λͺ¨λ μ€μ κ³Ό μλ΅μ΄ μ΄κΈ°νλμμ΅λλ€.")
|
41 |
|
42 |
# νμ μλ΅ νμ΄μ§
|
43 |
elif user_type == "νμ μλ΅":
|
|
|
45 |
if os.path.exists(survey_file_path):
|
46 |
df = pd.read_csv(survey_file_path)
|
47 |
question = df['question'][0]
|
48 |
+
use_options = df['use_options'][0]
|
49 |
+
options = eval(df['options'][0]) if use_options else []
|
50 |
|
51 |
st.write(f"### {question}")
|
|
|
52 |
|
53 |
+
if use_options and options:
|
54 |
+
options.append("κΈ°ν (μ§μ μ
λ ₯)")
|
55 |
+
selected_option = st.radio("λ΅λ³μ μ ννμΈμ:", options)
|
56 |
+
if selected_option == "κΈ°ν (μ§μ μ
λ ₯)":
|
57 |
+
answer = st.text_area("μ£Όκ΄μ λ΅λ³μ μ
λ ₯νμΈμ:")
|
58 |
+
else:
|
59 |
+
answer = selected_option
|
60 |
else:
|
61 |
+
answer = st.text_area("μ£Όκ΄μ λ΅λ³μ μ
λ ₯νμΈμ:")
|
62 |
|
63 |
if st.button("λ΅λ³ μ μΆ"):
|
64 |
# μλ΅ λ°μ΄ν° μ μ₯
|
65 |
response_data = {
|
66 |
+
'μλ΅': [answer]
|
|
|
67 |
}
|
68 |
response_df = pd.DataFrame(response_data)
|
69 |
|
|
|
73 |
response_df.to_csv(responses_file_path, index=False)
|
74 |
|
75 |
st.success("λ΅λ³μ΄ μ μΆλμμ΅λλ€!")
|
76 |
+
st.write("### λ΅λ³ μ μΆ μλ£")
|
77 |
+
st.write(f"κ·νμ λ΅λ³: {answer}")
|
78 |
|
|
|
|
|
|
|
79 |
else:
|
80 |
st.warning("μ€λ¬Έμ΄ μμ§ μ€μ λμ§ μμμ΅λλ€. κ΅μ¬μκ² λ¬ΈμνμΈμ.")
|
81 |
|
|
|
84 |
st.title("μ€λ¬Έ κ²°κ³Ό νμΈ")
|
85 |
if os.path.exists(responses_file_path):
|
86 |
df = pd.read_csv(responses_file_path)
|
87 |
+
st.write("### μλ΅ κ²°κ³Ό")
|
88 |
+
if os.path.exists(survey_file_path):
|
89 |
+
survey_df = pd.read_csv(survey_file_path)
|
90 |
+
use_options = survey_df['use_options'][0]
|
91 |
+
if use_options:
|
92 |
+
st.bar_chart(df['μλ΅'].value_counts())
|
93 |
+
st.table(df)
|
94 |
else:
|
95 |
st.warning("μμ§ μ μΆλ λ΅λ³μ΄ μμ΅λλ€.")
|