rosemariafontana commited on
Commit
bb44945
·
verified ·
1 Parent(s): 9f31d16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -7
app.py CHANGED
@@ -24,21 +24,34 @@ def process_survey(submission_id):
24
  response.raise_for_status()
25
  data = response.json()
26
  #actual_data = data[0]['data']
27
- return data
28
 
29
  except Exception as e:
30
  return f"An error occurred while fetching the survey data: {e}"
31
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- def display_survey():
 
 
 
34
  base_url = "https://app.surveystack.io/groups/"
35
  group_id = "5e95e368fbbf75000146a006" # Group ID "Our-Sci"
36
- survey_id = "671fc52152e3225d7de349e6"
37
 
38
  # Construct the full URL using urljoin to ensure proper formatting
39
  survey_url = urljoin(base_url, f"{group_id}/surveys/{survey_id}/submissions/new")
40
 
41
- print("DISPLAY_SURVEY")
42
  print(survey_url)
43
 
44
  iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
@@ -52,18 +65,26 @@ with gr.Blocks() as app:
52
  # submit_button = gr.Button("Load Survey")
53
 
54
  with gr.Row():
55
- survey_output = gr.HTML(value=display_survey())
56
 
57
  #submit_button.click(fn=display_survey, inputs=surveyID_input, outputs=survey_output)
58
 
59
  survey_submission_ID = gr.Textbox(label="Before submitting your surveystack survey, PLEASE record your submission ID. Type it here.")
60
 
61
- hf_submit_button = gr.Button("Parse Input Data")
62
 
63
  get_survey_back = gr.Textbox(label="Data from SurveyStack")
64
 
65
- hf_submit_button.click(fn=process_survey, inputs=[survey_submission_ID], outputs=get_survey_back)
 
 
 
 
 
 
 
66
 
 
67
 
68
 
69
  app.launch()
 
24
  response.raise_for_status()
25
  data = response.json()
26
  #actual_data = data[0]['data']
27
+ return data, gr.HTML(visible=True)
28
 
29
  except Exception as e:
30
  return f"An error occurred while fetching the survey data: {e}"
31
 
32
+ def display_parameter_survey():
33
+ base_url = "https://app.surveystack.io/groups/"
34
+ group_id = "5e95e368fbbf75000146a006" # Group ID "Our-Sci"
35
+ survey_id = "671fe2d352e3225d7de34afc" # survey id for parameter survey
36
+
37
+ # Construct the full URL using urljoin to ensure proper formatting
38
+ survey_url = urljoin(base_url, f"{group_id}/surveys/{survey_id}/submissions/new")
39
+
40
+ print("PARAMETER_SURVEY")
41
+ print(survey_url)
42
 
43
+ iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
44
+ return iframe_html
45
+
46
+ def display_data_survey():
47
  base_url = "https://app.surveystack.io/groups/"
48
  group_id = "5e95e368fbbf75000146a006" # Group ID "Our-Sci"
49
+ survey_id = "671fc52152e3225d7de349e6" # survey id for data survey
50
 
51
  # Construct the full URL using urljoin to ensure proper formatting
52
  survey_url = urljoin(base_url, f"{group_id}/surveys/{survey_id}/submissions/new")
53
 
54
+ print("DATA_SURVEY")
55
  print(survey_url)
56
 
57
  iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
 
65
  # submit_button = gr.Button("Load Survey")
66
 
67
  with gr.Row():
68
+ data_survey_output = gr.HTML(value=display_data_survey())
69
 
70
  #submit_button.click(fn=display_survey, inputs=surveyID_input, outputs=survey_output)
71
 
72
  survey_submission_ID = gr.Textbox(label="Before submitting your surveystack survey, PLEASE record your submission ID. Type it here.")
73
 
74
+ data_submit_button = gr.Button("Parse Data")
75
 
76
  get_survey_back = gr.Textbox(label="Data from SurveyStack")
77
 
78
+ data_submit_button.click(fn=process_survey, inputs=survey_submission_ID, outputs=[get_survey_back, parameter_survey_output])
79
+
80
+ with gr.Row():
81
+ parameter_survey_output = gr.HTML(value=display_parameter_survey(), visible=False)
82
+
83
+ param_submit_button = gr.Button("Parse Parameters")
84
+
85
+ get_survey_back2 = gr.Textbox(label="Parameters from SurveyStack")
86
 
87
+ param_submit_button.click(fn=process_survey, inputs=survey_submission_ID, outputs=[get_survey_back2])
88
 
89
 
90
  app.launch()