rosemariafontana commited on
Commit
ce58c1c
·
verified ·
1 Parent(s): 47bd7a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -29
app.py CHANGED
@@ -5,22 +5,12 @@ from urllib.parse import urljoin, urlencode, quote
5
  from gradio_toggle import Toggle
6
  import json
7
  import yaml
8
- from fastapi import FastAPI
9
- from fastapi.responses import JSONResponse
10
-
11
- app = FastAPI()
12
 
13
  from process_data import parse_survey_stack_parameters, parse_survey_stack_data, process_specifications
14
 
15
  global parsed_input_data
16
  global original_outputs, yaml_outputs
17
 
18
- @app.post("/submit")
19
- async def submit_data(data: dict):
20
- print("Received submission data:", data)
21
- # get submission ID
22
- return JSONResponse(content={"message": "Data processed successfully!", "submission_id": submission_id})
23
-
24
  def process_survey(button_type, survey_submission_ID):
25
  if button_type == 'data':
26
  survey_id = "671fc52152e3225d7de349e6"
@@ -79,25 +69,7 @@ def display_parameter_survey():
79
  print(survey_url)
80
 
81
 
82
- #iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
83
- iframe_html = f"""
84
- <iframe src="{survey_url}" width="100%" height="600px"></iframe>
85
- <script>
86
- window.addEventListener("message", (event) => {{
87
- if (event.origin === "https://app.surveystack.io" && event.data.type === "SUBMISSION_SUBMIT_SUCCESS") {{
88
- const data = event.data.payload.submissionId;
89
- console.log("Submission Data:", data);
90
-
91
- fetch('/submit', {{
92
- method: 'POST',
93
- headers: {{
94
- 'Content-Type': 'application/json'
95
- }},
96
- body: JSON.stringify({{submission_id: data}})
97
- }});
98
- }});
99
- </script>
100
- """
101
 
102
  return iframe_html
103
 
 
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
 
11
  global parsed_input_data
12
  global original_outputs, yaml_outputs
13
 
 
 
 
 
 
 
14
  def process_survey(button_type, survey_submission_ID):
15
  if button_type == 'data':
16
  survey_id = "671fc52152e3225d7de349e6"
 
69
  print(survey_url)
70
 
71
 
72
+ iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  return iframe_html
75