unity4ar commited on
Commit
5cb944e
·
verified ·
1 Parent(s): e9ef2b5

Expose `demo` at module scope so Gradio SDK runner can launch the gr.Server app

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -1852,10 +1852,16 @@ def _game_log_text(state: GameState) -> str:
1852
  return "\n".join(f"T{entry['turn_number']} {entry['kind']}: {entry['message']}" for entry in state.game_log[-12:])
1853
 
1854
 
 
 
 
 
 
 
1855
  if __name__ == "__main__":
1856
  # Bind address/port are env-overridable so the same entrypoint works locally
1857
  # (default loopback) and inside a container / Hugging Face Space, where the
1858
  # app must listen on 0.0.0.0 and the platform supplies the port.
1859
  host = os.getenv("PHANTOM_GRID_HOST", "127.0.0.1")
1860
  port = int(os.getenv("PORT") or os.getenv("PHANTOM_GRID_PORT") or "7860")
1861
- build_app().launch(server_name=host, server_port=port, allowed_paths=[str(PROJECT_ROOT)])
 
1852
  return "\n".join(f"T{entry['turn_number']} {entry['kind']}: {entry['message']}" for entry in state.game_log[-12:])
1853
 
1854
 
1855
+ # Hugging Face Spaces' Gradio SDK runner imports this module and looks for a
1856
+ # top-level `demo` (gr.Blocks / gr.Server) to launch. Locally we still gate the
1857
+ # manual launch behind __main__ so `python app.py` works as before.
1858
+ demo = build_app()
1859
+
1860
+
1861
  if __name__ == "__main__":
1862
  # Bind address/port are env-overridable so the same entrypoint works locally
1863
  # (default loopback) and inside a container / Hugging Face Space, where the
1864
  # app must listen on 0.0.0.0 and the platform supplies the port.
1865
  host = os.getenv("PHANTOM_GRID_HOST", "127.0.0.1")
1866
  port = int(os.getenv("PORT") or os.getenv("PHANTOM_GRID_PORT") or "7860")
1867
+ demo.launch(server_name=host, server_port=port, allowed_paths=[str(PROJECT_ROOT)])