Spaces:
Sleeping
Sleeping
arxivgpt kim
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -106,20 +106,32 @@ scores = [[1, 0],
|
|
106 |
[3, 2, 1, 0]
|
107 |
]
|
108 |
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
grade, definition = get_grade(total_score)
|
112 |
-
|
|
|
113 |
webhook_url = "https://hooks.zapier.com/hooks/catch/14523965/3egrs04/"
|
114 |
data = {
|
115 |
-
"project_name":
|
116 |
-
"contact_name":
|
117 |
-
"contact_email":
|
118 |
-
"contact_phone":
|
119 |
"responses": answers # ์ฌ์ฉ์์ ์๋ต๋ค
|
120 |
}
|
121 |
response = requests.post(webhook_url, json=data)
|
122 |
-
|
123 |
if response.status_code == 200:
|
124 |
print("Data sent to Zapier successfully.")
|
125 |
else:
|
@@ -127,6 +139,7 @@ def calculate_score(*answers):
|
|
127 |
return total_score, grade, definition
|
128 |
|
129 |
|
|
|
130 |
def get_grade(total_score):
|
131 |
converted_score = (total_score)
|
132 |
|
@@ -149,7 +162,6 @@ css = """
|
|
149 |
footer {
|
150 |
visibility: hidden;
|
151 |
}
|
152 |
-
|
153 |
/* ๋ฒํผ ์คํ์ผ๋ง */
|
154 |
button {
|
155 |
background: linear-gradient(135deg, #007BFF, #004085);
|
@@ -163,54 +175,43 @@ button {
|
|
163 |
cursor: pointer;
|
164 |
transition: background 0.5s ease;
|
165 |
}
|
166 |
-
|
167 |
button:hover {
|
168 |
background: linear-gradient(135deg, #0056b3, #002752);
|
169 |
}
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
/* ํญ ์๊น ๋ณ๊ฒฝ์ ์ํ CSS */
|
174 |
/* ํญ ๋ฒํผ ์คํ์ผ */
|
175 |
.tab-container .tab {
|
176 |
background-color: #f0f0f0; /* ์ฐํ ํ์์ผ๋ก ๋ฐฐ๊ฒฝ์ ๋ณ๊ฒฝ */
|
177 |
color: #333; /* ๊ธ์์ ๋ณ๊ฒฝ */
|
178 |
}
|
179 |
-
|
180 |
/* ์ ํ๋ ํญ ์คํ์ผ */
|
181 |
.tab-container .tab.selected {
|
182 |
background-color: #d9d9d9; /* ์ ํ๋ ํญ์ ๋ฐฐ๊ฒฝ์์ ๋ ์ด๋์ด ํ์์ผ๋ก ๋ณ๊ฒฝ */
|
183 |
color: #000; /* ์ ํ๋ ํญ์ ๊ธ์์์ ๊ฒ์ ์์ผ๋ก ๋ณ๊ฒฝ */
|
184 |
border-bottom: 2px solid #007BFF; /* ์ ํ๋ ํญ์ ํ๋จ ํ
๋๋ฆฌ ์คํ์ผ */
|
185 |
}
|
186 |
-
|
187 |
/* ํญ ์ปจํ
์ธ ์์ญ ์คํ์ผ */
|
188 |
.tab-content {
|
189 |
border: 1px solid #dcdcdc; /* ํญ ์ปจํ
์ธ ์์ญ์ ํ
๋๋ฆฌ ์์ */
|
190 |
background-color: #f9f9f9; /* ํญ ์ปจํ
์ธ ์์ญ์ ๋ฐฐ๊ฒฝ์ */
|
191 |
}
|
192 |
-
|
193 |
/* ์
๋ ฅ ํผ ๋ฐ ์ถ๋ ฅ ํผ ์คํ์ผ๋ง */
|
194 |
.input, .output {
|
195 |
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); /* ์
์ฒด๊ฐ์ ์ฃผ๋ ๊ทธ๋ฆผ์ ์ถ๊ฐ */
|
196 |
border: 2px solid #17a2b8; /* ์ปฌ๋ฌ ํ
๋๋ฆฌ ์ ์ฉ */
|
197 |
border-radius: 5px; /* ํ
๋๋ฆฌ ๋ฅ๊ธ๊ฒ */
|
198 |
}
|
199 |
-
|
200 |
.input:hover, .output:hover {
|
201 |
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2); /* ํธ๋ฒ ์ ๋ ํฐ ๊ทธ๋ฆผ์ ํจ๊ณผ */
|
202 |
}
|
203 |
-
|
204 |
/* ํ์ดํ๊ณผ ์ค๋ช
๊ธ ๊ฐ์ด๋ฐ ์ ๋ ฌ ์ถ๊ฐ */
|
205 |
.markdown {
|
206 |
text-align: center; /* ํ
์คํธ๋ฅผ ๊ฐ์ด๋ฐ ์ ๋ ฌ */
|
207 |
-
|
208 |
}
|
209 |
/* ๊ฒฐ๊ณผ ์ถ๋ ฅ ์ปดํฌ๋ํธ์ ๊ธ์ ํฌ๊ธฐ 3๋ฐฐ๋ก ์กฐ์ */
|
210 |
.output {
|
211 |
font-size: 300%; /* ๊ธฐ๋ณธ ๊ธ์ ํฌ๊ธฐ์ 2๋ฐฐ */
|
212 |
}
|
213 |
-
|
214 |
/* ํญ ํด๋ฆญ ์ ๋๋ฆฐ ํญ์ ์ ์ฉ๋ ์คํ์ผ */
|
215 |
.tab_button.selected {
|
216 |
background-color: #007BFF; /* ์ ํ๋ ํญ์ ๋ฐฐ๊ฒฝ์์ ๋ณ๊ฒฝ */
|
@@ -232,6 +233,8 @@ with gr.Blocks(css=css, title="์ฝ๋ ์ดํ
์
ํ ์ง๋จ ์๋น์ค") as demo:
|
|
232 |
contact_phone = gr.Textbox(label="์ฐ๋ฝ์ฒ")
|
233 |
contact_email = gr.Textbox(label="์ด๋ฉ์ผ ์ฃผ์")
|
234 |
|
|
|
|
|
235 |
with gr.Tab("1๋จ๊ณ"):
|
236 |
answer1 = gr.Radio(choices=options[0], label=questions[0])
|
237 |
answer2 = gr.Radio(choices=options[1], label=questions[1])
|
@@ -272,19 +275,20 @@ with gr.Blocks(css=css, title="์ฝ๋ ์ดํ
์
ํ ์ง๋จ ์๋น์ค") as demo:
|
|
272 |
answer30 = gr.Radio(choices=options[29], label=questions[29])
|
273 |
answer31 = gr.Radio(choices=options[30], label=questions[30])
|
274 |
answer32 = gr.Radio(choices=options[31], label=questions[31])
|
275 |
-
|
|
|
276 |
|
277 |
submit_btn = gr.Button("์
ํ ์ง๋จ ์๋น์ค ๊ฒฐ๊ณผ ๋ณด๊ธฐ")
|
278 |
score_output = gr.Number(label="์ด์ (73์ ๋ง์ )")
|
279 |
grade_output = gr.Text(label="๋ฑ๊ธ")
|
280 |
definition_output = gr.Textbox(label="๋ฑ๊ธ ์ ์: ์
ํ์ง๋จ ๊ฒฐ๊ณผ๋ ์ดค์ํ์ ํญ๋ชฉ์ ์ฌ์ฉ์์ ์์์ ๋ต๋ณ์ ๊ธฐ๋ฐํ ๊ฒฐ๊ณผ์
๋๋ค. ๋ฐ๋ผ์ ๋ณธ ๊ฒฐ๊ณผ๋ ์ฝ๋ ์ดํ
์ ๊ณต์ ํ๊ฐ ๊ฒฐ๊ณผ๊ฐ ์๋์ ์๋ ค๋๋ฆฝ๋๋ค.")
|
281 |
|
|
|
|
|
282 |
submit_btn.click(
|
283 |
-
fn=calculate_score,
|
284 |
-
inputs=[answer1, answer2, answer3, answer4, answer5, answer6, answer7, answer8, answer9, answer10, answer11, answer12, answer13, answer14, answer15, answer16, answer17, answer18, answer19, answer20, answer21, answer22, answer23, answer24, answer25, answer26, answer27, answer28, answer29, answer30, answer31, answer32],
|
285 |
outputs=[score_output, grade_output, definition_output]
|
286 |
)
|
287 |
|
288 |
-
demo.launch()
|
289 |
-
|
290 |
-
|
|
|
106 |
[3, 2, 1, 0]
|
107 |
]
|
108 |
|
109 |
+
|
110 |
+
|
111 |
+
def calculate_score(project_info, answers):
|
112 |
+
total_score = 0
|
113 |
+
for i, answer in enumerate(answers):
|
114 |
+
if answer is not None:
|
115 |
+
try:
|
116 |
+
answer_index = options[i].index(answer)
|
117 |
+
total_score += scores[i][answer_index]
|
118 |
+
except ValueError:
|
119 |
+
print(f"Invalid answer: {answer} for question {i+1}")
|
120 |
+
else:
|
121 |
+
print(f"No answer for question {i+1}, assigning score of 0.")
|
122 |
grade, definition = get_grade(total_score)
|
123 |
+
|
124 |
+
# Zapier Webhook์ผ๋ก ๋ฐ์ดํฐ ์ ์ก
|
125 |
webhook_url = "https://hooks.zapier.com/hooks/catch/14523965/3egrs04/"
|
126 |
data = {
|
127 |
+
"project_name": project_info[0],
|
128 |
+
"contact_name": project_info[1],
|
129 |
+
"contact_email": project_info[2],
|
130 |
+
"contact_phone": project_info[3],
|
131 |
"responses": answers # ์ฌ์ฉ์์ ์๋ต๋ค
|
132 |
}
|
133 |
response = requests.post(webhook_url, json=data)
|
134 |
+
|
135 |
if response.status_code == 200:
|
136 |
print("Data sent to Zapier successfully.")
|
137 |
else:
|
|
|
139 |
return total_score, grade, definition
|
140 |
|
141 |
|
142 |
+
|
143 |
def get_grade(total_score):
|
144 |
converted_score = (total_score)
|
145 |
|
|
|
162 |
footer {
|
163 |
visibility: hidden;
|
164 |
}
|
|
|
165 |
/* ๋ฒํผ ์คํ์ผ๋ง */
|
166 |
button {
|
167 |
background: linear-gradient(135deg, #007BFF, #004085);
|
|
|
175 |
cursor: pointer;
|
176 |
transition: background 0.5s ease;
|
177 |
}
|
|
|
178 |
button:hover {
|
179 |
background: linear-gradient(135deg, #0056b3, #002752);
|
180 |
}
|
|
|
|
|
|
|
181 |
/* ํญ ์๊น ๋ณ๊ฒฝ์ ์ํ CSS */
|
182 |
/* ํญ ๋ฒํผ ์คํ์ผ */
|
183 |
.tab-container .tab {
|
184 |
background-color: #f0f0f0; /* ์ฐํ ํ์์ผ๋ก ๋ฐฐ๊ฒฝ์ ๋ณ๊ฒฝ */
|
185 |
color: #333; /* ๊ธ์์ ๋ณ๊ฒฝ */
|
186 |
}
|
|
|
187 |
/* ์ ํ๋ ํญ ์คํ์ผ */
|
188 |
.tab-container .tab.selected {
|
189 |
background-color: #d9d9d9; /* ์ ํ๋ ํญ์ ๋ฐฐ๊ฒฝ์์ ๋ ์ด๋์ด ํ์์ผ๋ก ๋ณ๊ฒฝ */
|
190 |
color: #000; /* ์ ํ๋ ํญ์ ๊ธ์์์ ๊ฒ์ ์์ผ๋ก ๋ณ๊ฒฝ */
|
191 |
border-bottom: 2px solid #007BFF; /* ์ ํ๋ ํญ์ ํ๋จ ํ
๋๋ฆฌ ์คํ์ผ */
|
192 |
}
|
|
|
193 |
/* ํญ ์ปจํ
์ธ ์์ญ ์คํ์ผ */
|
194 |
.tab-content {
|
195 |
border: 1px solid #dcdcdc; /* ํญ ์ปจํ
์ธ ์์ญ์ ํ
๋๋ฆฌ ์์ */
|
196 |
background-color: #f9f9f9; /* ํญ ์ปจํ
์ธ ์์ญ์ ๋ฐฐ๊ฒฝ์ */
|
197 |
}
|
|
|
198 |
/* ์
๋ ฅ ํผ ๋ฐ ์ถ๋ ฅ ํผ ์คํ์ผ๋ง */
|
199 |
.input, .output {
|
200 |
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); /* ์
์ฒด๊ฐ์ ์ฃผ๋ ๊ทธ๋ฆผ์ ์ถ๊ฐ */
|
201 |
border: 2px solid #17a2b8; /* ์ปฌ๋ฌ ํ
๋๋ฆฌ ์ ์ฉ */
|
202 |
border-radius: 5px; /* ํ
๋๋ฆฌ ๋ฅ๊ธ๊ฒ */
|
203 |
}
|
|
|
204 |
.input:hover, .output:hover {
|
205 |
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2); /* ํธ๋ฒ ์ ๋ ํฐ ๊ทธ๋ฆผ์ ํจ๊ณผ */
|
206 |
}
|
|
|
207 |
/* ํ์ดํ๊ณผ ์ค๋ช
๊ธ ๊ฐ์ด๋ฐ ์ ๋ ฌ ์ถ๊ฐ */
|
208 |
.markdown {
|
209 |
text-align: center; /* ํ
์คํธ๋ฅผ ๊ฐ์ด๋ฐ ์ ๋ ฌ */
|
|
|
210 |
}
|
211 |
/* ๊ฒฐ๊ณผ ์ถ๋ ฅ ์ปดํฌ๋ํธ์ ๊ธ์ ํฌ๊ธฐ 3๋ฐฐ๋ก ์กฐ์ */
|
212 |
.output {
|
213 |
font-size: 300%; /* ๊ธฐ๋ณธ ๊ธ์ ํฌ๊ธฐ์ 2๋ฐฐ */
|
214 |
}
|
|
|
215 |
/* ํญ ํด๋ฆญ ์ ๋๋ฆฐ ํญ์ ์ ์ฉ๋ ์คํ์ผ */
|
216 |
.tab_button.selected {
|
217 |
background-color: #007BFF; /* ์ ํ๋ ํญ์ ๋ฐฐ๊ฒฝ์์ ๋ณ๊ฒฝ */
|
|
|
233 |
contact_phone = gr.Textbox(label="์ฐ๋ฝ์ฒ")
|
234 |
contact_email = gr.Textbox(label="์ด๋ฉ์ผ ์ฃผ์")
|
235 |
|
236 |
+
|
237 |
+
|
238 |
with gr.Tab("1๋จ๊ณ"):
|
239 |
answer1 = gr.Radio(choices=options[0], label=questions[0])
|
240 |
answer2 = gr.Radio(choices=options[1], label=questions[1])
|
|
|
275 |
answer30 = gr.Radio(choices=options[29], label=questions[29])
|
276 |
answer31 = gr.Radio(choices=options[30], label=questions[30])
|
277 |
answer32 = gr.Radio(choices=options[31], label=questions[31])
|
278 |
+
|
279 |
+
|
280 |
|
281 |
submit_btn = gr.Button("์
ํ ์ง๋จ ์๋น์ค ๊ฒฐ๊ณผ ๋ณด๊ธฐ")
|
282 |
score_output = gr.Number(label="์ด์ (73์ ๋ง์ )")
|
283 |
grade_output = gr.Text(label="๋ฑ๊ธ")
|
284 |
definition_output = gr.Textbox(label="๋ฑ๊ธ ์ ์: ์
ํ์ง๋จ ๊ฒฐ๊ณผ๋ ์ดค์ํ์ ํญ๋ชฉ์ ์ฌ์ฉ์์ ์์์ ๋ต๋ณ์ ๊ธฐ๋ฐํ ๊ฒฐ๊ณผ์
๋๋ค. ๋ฐ๋ผ์ ๋ณธ ๊ฒฐ๊ณผ๋ ์ฝ๋ ์ดํ
์ ๊ณต์ ํ๊ฐ ๊ฒฐ๊ณผ๊ฐ ์๋์ ์๋ ค๋๋ฆฝ๋๋ค.")
|
285 |
|
286 |
+
|
287 |
+
|
288 |
submit_btn.click(
|
289 |
+
fn=lambda project_name, contact_name, contact_phone, contact_email, *answers: calculate_score([project_name, contact_name, contact_phone, contact_email], answers),
|
290 |
+
inputs=[project_name, contact_name, contact_phone, contact_email] + [answer1, answer2, answer3, answer4, answer5, answer6, answer7, answer8, answer9, answer10, answer11, answer12, answer13, answer14, answer15, answer16, answer17, answer18, answer19, answer20, answer21, answer22, answer23, answer24, answer25, answer26, answer27, answer28, answer29, answer30, answer31, answer32],
|
291 |
outputs=[score_output, grade_output, definition_output]
|
292 |
)
|
293 |
|
294 |
+
demo.launch()
|
|
|
|