Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
from urllib.parse import urljoin, urlencode, quote
|
| 4 |
|
| 5 |
-
def process_survey(
|
| 6 |
survey_id = "671fc52152e3225d7de349e6"
|
| 7 |
base_url = "https://app.surveystack.io/api/submissions"
|
| 8 |
params = {
|
|
@@ -15,7 +15,7 @@ def process_survey(survey_number, submission_id):
|
|
| 15 |
|
| 16 |
survey_url = f"{base_url}?{encoded_params}&match={match_param}"
|
| 17 |
|
| 18 |
-
print("
|
| 19 |
print("PROCESS_SURVEY")
|
| 20 |
print(survey_url)
|
| 21 |
|
|
@@ -25,7 +25,7 @@ def process_survey(survey_number, submission_id):
|
|
| 25 |
data = response.json()
|
| 26 |
#actual_data = data[0]['data']
|
| 27 |
|
| 28 |
-
if
|
| 29 |
return data, gr.HTML(visible=True), gr.Textbox(visible=False), gr.Textbox(visible=False), gr.Button(visible=False), gr.Textbox(visible=False)
|
| 30 |
else:
|
| 31 |
return data
|
|
@@ -71,14 +71,12 @@ with gr.Blocks() as app:
|
|
| 71 |
|
| 72 |
get_survey_back = gr.Textbox(label="Data from SurveyStack")
|
| 73 |
|
| 74 |
-
survey_number = 0
|
| 75 |
-
|
| 76 |
with gr.Row():
|
| 77 |
parameter_survey_output = gr.HTML(value=display_parameter_survey(), visible=False)
|
| 78 |
|
| 79 |
#data_submit_button.click(fn=process_survey, inputs=[survey_submission_ID, survey_number], outputs=[get_survey_back, parameter_survey_output, data_survey_output, survey_submission_ID, data_submit_button, get_survey_back])
|
| 80 |
data_submit_button.click(
|
| 81 |
-
lambda
|
| 82 |
inputs=[survey_submission_ID],
|
| 83 |
outputs=[get_survey_back, parameter_survey_output, data_survey_output, survey_submission_ID, data_submit_button, get_survey_back]
|
| 84 |
)
|
|
@@ -89,11 +87,10 @@ with gr.Blocks() as app:
|
|
| 89 |
|
| 90 |
get_survey_back2 = gr.Textbox(label="Parameters from SurveyStack")
|
| 91 |
|
| 92 |
-
survey_number = 77
|
| 93 |
|
| 94 |
#param_submit_button.click(fn=process_survey, inputs=[survey2_submission_ID, survey_number], outputs=[get_survey_back2])
|
| 95 |
param_submit_button.click(
|
| 96 |
-
lambda
|
| 97 |
inputs=survey2_submission_ID,
|
| 98 |
outputs=get_survey_back2
|
| 99 |
)
|
|
|
|
| 2 |
import requests
|
| 3 |
from urllib.parse import urljoin, urlencode, quote
|
| 4 |
|
| 5 |
+
def process_survey(button_type, submission_id):
|
| 6 |
survey_id = "671fc52152e3225d7de349e6"
|
| 7 |
base_url = "https://app.surveystack.io/api/submissions"
|
| 8 |
params = {
|
|
|
|
| 15 |
|
| 16 |
survey_url = f"{base_url}?{encoded_params}&match={match_param}"
|
| 17 |
|
| 18 |
+
print("Button Type: " + button_type)
|
| 19 |
print("PROCESS_SURVEY")
|
| 20 |
print(survey_url)
|
| 21 |
|
|
|
|
| 25 |
data = response.json()
|
| 26 |
#actual_data = data[0]['data']
|
| 27 |
|
| 28 |
+
if button_type == 'data':
|
| 29 |
return data, gr.HTML(visible=True), gr.Textbox(visible=False), gr.Textbox(visible=False), gr.Button(visible=False), gr.Textbox(visible=False)
|
| 30 |
else:
|
| 31 |
return data
|
|
|
|
| 71 |
|
| 72 |
get_survey_back = gr.Textbox(label="Data from SurveyStack")
|
| 73 |
|
|
|
|
|
|
|
| 74 |
with gr.Row():
|
| 75 |
parameter_survey_output = gr.HTML(value=display_parameter_survey(), visible=False)
|
| 76 |
|
| 77 |
#data_submit_button.click(fn=process_survey, inputs=[survey_submission_ID, survey_number], outputs=[get_survey_back, parameter_survey_output, data_survey_output, survey_submission_ID, data_submit_button, get_survey_back])
|
| 78 |
data_submit_button.click(
|
| 79 |
+
lambda button_type: process_survey("data", button_type),
|
| 80 |
inputs=[survey_submission_ID],
|
| 81 |
outputs=[get_survey_back, parameter_survey_output, data_survey_output, survey_submission_ID, data_submit_button, get_survey_back]
|
| 82 |
)
|
|
|
|
| 87 |
|
| 88 |
get_survey_back2 = gr.Textbox(label="Parameters from SurveyStack")
|
| 89 |
|
|
|
|
| 90 |
|
| 91 |
#param_submit_button.click(fn=process_survey, inputs=[survey2_submission_ID, survey_number], outputs=[get_survey_back2])
|
| 92 |
param_submit_button.click(
|
| 93 |
+
lambda button_type: process_survey("param", button_type),
|
| 94 |
inputs=survey2_submission_ID,
|
| 95 |
outputs=get_survey_back2
|
| 96 |
)
|