Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,21 @@ with gr.Blocks(title="Static Assets Demo") as demo:
|
|
36 |
# 3) Launch! allowed_paths keeps working even if you remove set_static_paths.
|
37 |
# --------------------------------------------------------------------
|
38 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
demo.launch(
|
40 |
server_name="0.0.0.0",
|
41 |
server_port=7860,
|
|
|
36 |
# 3) Launch! allowed_paths keeps working even if you remove set_static_paths.
|
37 |
# --------------------------------------------------------------------
|
38 |
if __name__ == "__main__":
|
39 |
+
# 添加自定义JS抑制重复渲染
|
40 |
+
demo.load(
|
41 |
+
None,
|
42 |
+
None,
|
43 |
+
None,
|
44 |
+
_js="""
|
45 |
+
() => {
|
46 |
+
// 标记已初始化,避免重复操作
|
47 |
+
if (!window.__gradio_initialized) {
|
48 |
+
window.__gradio_initialized = true;
|
49 |
+
// 这里放置仅需执行一次的代码
|
50 |
+
}
|
51 |
+
}
|
52 |
+
"""
|
53 |
+
)
|
54 |
demo.launch(
|
55 |
server_name="0.0.0.0",
|
56 |
server_port=7860,
|