github-actions[bot] commited on
Commit
0c2c0f1
·
1 Parent(s): 5900a5b

Sync from GitHub main @ 9b3d8fb228c968fd1d31e2a76197fb0a25a602d2

Browse files
Files changed (1) hide show
  1. start.py +10 -2
start.py CHANGED
@@ -25,15 +25,23 @@ def run_gradio():
25
  """Build and launch Gradio UI on the Space's PORT."""
26
  print("[start] about to launch gradio on PORT=", os.getenv("PORT"), flush=True)
27
  from demo.app import build_ui
 
28
 
29
  demo = build_ui()
30
- demo.launch(
 
31
  server_name="0.0.0.0",
32
  server_port=int(os.getenv("PORT", "7860")),
33
- show_api=False,
34
  debug=False,
35
  )
36
 
 
 
 
 
 
 
 
37
 
38
  if __name__ == "__main__":
39
  # Start FastAPI in background thread
 
25
  """Build and launch Gradio UI on the Space's PORT."""
26
  print("[start] about to launch gradio on PORT=", os.getenv("PORT"), flush=True)
27
  from demo.app import build_ui
28
+ import inspect
29
 
30
  demo = build_ui()
31
+
32
+ launch_kwargs = dict(
33
  server_name="0.0.0.0",
34
  server_port=int(os.getenv("PORT", "7860")),
 
35
  debug=False,
36
  )
37
 
38
+ # Backward/forward compatibility: some gradio versions don't support `show_api`
39
+ sig = inspect.signature(demo.launch)
40
+ if "show_api" in sig.parameters:
41
+ launch_kwargs["show_api"] = False
42
+
43
+ demo.launch(**launch_kwargs)
44
+
45
 
46
  if __name__ == "__main__":
47
  # Start FastAPI in background thread