Commit
·
6531321
1
Parent(s):
b03175f
Refactor: Mount Gradio on FastAPI to expose API on port 7860
Browse files
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 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
|
| 94 |
# Start background services
|
| 95 |
if __name__ == "__main__":
|
| 96 |
-
# 1. Start
|
| 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 |
-
#
|
| 105 |
-
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|