rosemariafontana commited on
Commit
108cecc
·
verified ·
1 Parent(s): b7479fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -5,6 +5,7 @@ from urllib.parse import urljoin, urlencode, quote
5
  from gradio_toggle import Toggle
6
  import json
7
  import yaml
 
8
 
9
  from process_data import parse_survey_stack_parameters, parse_survey_stack_data, process_specifications
10
 
@@ -58,7 +59,11 @@ def process_survey(button_type, survey_submission_ID):
58
 
59
  except Exception as e:
60
  return f"An error occurred while fetching the survey data: {e}"
61
-
 
 
 
 
62
  def display_parameter_survey():
63
  base_url = "https://app.surveystack.io/groups/"
64
  group_id = "5e95e368fbbf75000146a006" # Group ID "Our-Sci"
@@ -69,6 +74,7 @@ def display_parameter_survey():
69
 
70
  print("PARAMETER_SURVEY")
71
  print(survey_url)
 
72
 
73
  #iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
74
  iframe_html = f"""
@@ -83,6 +89,11 @@ def display_parameter_survey():
83
  }});
84
  </script>
85
  """
 
 
 
 
 
86
  return iframe_html
87
 
88
  def display_data_survey():
 
5
  from gradio_toggle import Toggle
6
  import json
7
  import yaml
8
+ import PyV8
9
 
10
  from process_data import parse_survey_stack_parameters, parse_survey_stack_data, process_specifications
11
 
 
59
 
60
  except Exception as e:
61
  return f"An error occurred while fetching the survey data: {e}"
62
+
63
+ class Global(PyV8.JSClass):
64
+ def __init__(self):
65
+ self.mySubmissionData = None
66
+
67
  def display_parameter_survey():
68
  base_url = "https://app.surveystack.io/groups/"
69
  group_id = "5e95e368fbbf75000146a006" # Group ID "Our-Sci"
 
74
 
75
  print("PARAMETER_SURVEY")
76
  print(survey_url)
77
+
78
 
79
  #iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
80
  iframe_html = f"""
 
89
  }});
90
  </script>
91
  """
92
+ with PyV8.JSContext(Global()) as ctxt:
93
+ ctx.eval(ifram_html)
94
+ submission_data = ctxt.eval("window.huggingface.variables.mySubmissionData")
95
+ print("Submission Data:", submission_data)
96
+
97
  return iframe_html
98
 
99
  def display_data_survey():