Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
from urllib.parse import urljoin, urlencode, quote
|
|
@@ -11,6 +12,9 @@ global parsed_input_data
|
|
| 11 |
global original_outputs, yaml_outputs
|
| 12 |
|
| 13 |
def process_survey(button_type, survey_submission_ID):
|
|
|
|
|
|
|
|
|
|
| 14 |
if button_type == 'data':
|
| 15 |
survey_id = "671fc52152e3225d7de349e6"
|
| 16 |
|
|
@@ -67,6 +71,18 @@ def display_parameter_survey():
|
|
| 67 |
print(survey_url)
|
| 68 |
|
| 69 |
iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
return iframe_html
|
| 71 |
|
| 72 |
def display_data_survey():
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
from urllib.parse import urljoin, urlencode, quote
|
|
|
|
| 12 |
global original_outputs, yaml_outputs
|
| 13 |
|
| 14 |
def process_survey(button_type, survey_submission_ID):
|
| 15 |
+
my_variable = os.getenv("mySubmissionData")
|
| 16 |
+
print("HERE IS THE DATA " + my_variable)
|
| 17 |
+
|
| 18 |
if button_type == 'data':
|
| 19 |
survey_id = "671fc52152e3225d7de349e6"
|
| 20 |
|
|
|
|
| 71 |
print(survey_url)
|
| 72 |
|
| 73 |
iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
|
| 74 |
+
iframe_html = f"""
|
| 75 |
+
<iframe src="{survey_url}" width="100%" height="600px"></iframe>
|
| 76 |
+
<script>
|
| 77 |
+
window.addEventListener("message", (event) => {{
|
| 78 |
+
const submissionData = JSON.stringify(event.data);
|
| 79 |
+
console.log("Submission Data", submissionData);
|
| 80 |
+
window.huggingface.variables.mySubmissionData = submissionData;
|
| 81 |
+
}});
|
| 82 |
+
</script>
|
| 83 |
+
<div id="submissionData" style="display:none;"></div>
|
| 84 |
+
"""
|
| 85 |
+
|
| 86 |
return iframe_html
|
| 87 |
|
| 88 |
def display_data_survey():
|