vasanthfeb13 commited on
Commit
6531321
·
1 Parent(s): b03175f

Refactor: Mount Gradio on FastAPI to expose API on port 7860

Browse files
Files changed (1) hide show
  1. app.py +8 -21
app.py CHANGED
@@ -86,30 +86,17 @@ def start_local_node():
86
  except Exception as e:
87
  print(f"❌ Failed to start local node: {e}")
88
 
89
- def start_orchestrator_api():
90
- """Start the orchestrator API in the background."""
91
- print("🧠 Starting NACC Orchestrator API...")
92
- uvicorn.run(orchestrator_app, host="127.0.0.1", port=8888)
93
 
94
  # Start background services
95
  if __name__ == "__main__":
96
- # 1. Start the Orchestrator API in a thread
97
- api_thread = threading.Thread(target=start_orchestrator_api, daemon=True)
98
- api_thread.start()
99
-
100
- # 2. Start a Local Node in a thread (so the Space works out-of-the-box)
101
  node_thread = threading.Thread(target=start_local_node, daemon=True)
102
  node_thread.start()
103
 
104
- # 3. Give services a moment to spin up
105
- time.sleep(3)
106
-
107
- # 4. Launch the UI
108
- print("💻 Launching NACC UI...")
109
- # Pass the service instance to the UI if possible, or let it connect via API
110
- # The UI connects to http://localhost:8000/api by default or via config
111
- # We need to make sure the UI knows where the API is.
112
- # professional_ui_v2.py likely reads config or defaults to localhost:8000
113
-
114
- demo = create_ui()
115
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
86
  except Exception as e:
87
  print(f"❌ Failed to start local node: {e}")
88
 
89
+ # 5. Mount Gradio UI
90
+ print("💻 Mounting NACC UI...")
91
+ demo = create_ui()
92
+ app = gr.mount_gradio_app(app, demo, path="/")
93
 
94
  # Start background services
95
  if __name__ == "__main__":
96
+ # 1. Start a Local Node in a thread (so the Space works out-of-the-box)
 
 
 
 
97
  node_thread = threading.Thread(target=start_local_node, daemon=True)
98
  node_thread.start()
99
 
100
+ # 2. Start the combined app
101
+ print("🧠 Starting NACC Orchestrator API & UI on port 7860...")
102
+ uvicorn.run(app, host="0.0.0.0", port=7860)