Spaces:
Running
Running
Commit ·
da2a63c
1
Parent(s): 4dc666a
Ensure JS runs on Gradio 6
Browse files
app.py
CHANGED
|
@@ -661,7 +661,7 @@ CSS = """
|
|
| 661 |
}
|
| 662 |
"""
|
| 663 |
|
| 664 |
-
|
| 665 |
() => {
|
| 666 |
if (window.__rosaDemoInit) return;
|
| 667 |
window.__rosaDemoInit = true;
|
|
@@ -1450,11 +1450,13 @@ JS = """
|
|
| 1450 |
}
|
| 1451 |
"""
|
| 1452 |
|
|
|
|
|
|
|
| 1453 |
|
| 1454 |
if GRADIO_MAJOR >= 6:
|
| 1455 |
demo_context = gr.Blocks()
|
| 1456 |
else:
|
| 1457 |
-
demo_context = gr.Blocks(css=CSS, js=
|
| 1458 |
|
| 1459 |
with demo_context as demo:
|
| 1460 |
gr.HTML(
|
|
@@ -1501,5 +1503,5 @@ with demo_context as demo:
|
|
| 1501 |
if __name__ == "__main__":
|
| 1502 |
launch_kwargs = {}
|
| 1503 |
if GRADIO_MAJOR >= 6:
|
| 1504 |
-
launch_kwargs = {"css": CSS, "js":
|
| 1505 |
demo.launch(**launch_kwargs)
|
|
|
|
| 661 |
}
|
| 662 |
"""
|
| 663 |
|
| 664 |
+
JS_FUNC = """
|
| 665 |
() => {
|
| 666 |
if (window.__rosaDemoInit) return;
|
| 667 |
window.__rosaDemoInit = true;
|
|
|
|
| 1450 |
}
|
| 1451 |
"""
|
| 1452 |
|
| 1453 |
+
JS_BOOT = f"(function(){{ const init = {JS_FUNC}; init(); return init; }})()"
|
| 1454 |
+
|
| 1455 |
|
| 1456 |
if GRADIO_MAJOR >= 6:
|
| 1457 |
demo_context = gr.Blocks()
|
| 1458 |
else:
|
| 1459 |
+
demo_context = gr.Blocks(css=CSS, js=JS_BOOT)
|
| 1460 |
|
| 1461 |
with demo_context as demo:
|
| 1462 |
gr.HTML(
|
|
|
|
| 1503 |
if __name__ == "__main__":
|
| 1504 |
launch_kwargs = {}
|
| 1505 |
if GRADIO_MAJOR >= 6:
|
| 1506 |
+
launch_kwargs = {"css": CSS, "js": JS_BOOT, "ssr_mode": False}
|
| 1507 |
demo.launch(**launch_kwargs)
|