Ali2206 commited on
Commit
0abffce
·
1 Parent(s): b2d94dc

Fix router mounting - use include_router instead of mount for all agents

Browse files
AIAutomation/app/main.py CHANGED
@@ -41,7 +41,7 @@ app.add_middleware(
41
  allow_headers=["*"],
42
  )
43
 
44
- router = APIRouter(prefix="", tags=["invoice"])
45
 
46
 
47
  @router.get("/")
 
41
  allow_headers=["*"],
42
  )
43
 
44
+ router = APIRouter(prefix="/invoice", tags=["invoice"])
45
 
46
 
47
  @router.get("/")
AICommerce/app/main.py CHANGED
@@ -42,9 +42,22 @@ app.add_middleware(
42
  allow_headers=["*"],
43
  )
44
 
45
- router = APIRouter(prefix="", tags=["shop"])
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  @router.get("/health")
49
  def health() -> dict:
50
  return {
 
42
  allow_headers=["*"],
43
  )
44
 
45
+ router = APIRouter(prefix="/shop", tags=["shop"])
46
 
47
 
48
+ @router.get("/")
49
+ def index() -> FileResponse:
50
+ """Serve the AI Commerce page."""
51
+ base = os.path.dirname(__file__)
52
+ return FileResponse(os.path.join(base, "static", "index.html"))
53
+
54
+ # Add route without trailing slash for compatibility
55
+ @router.get("")
56
+ def index_no_slash() -> FileResponse:
57
+ """Serve the AI Commerce page (no trailing slash)."""
58
+ base = os.path.dirname(__file__)
59
+ return FileResponse(os.path.join(base, "static", "index.html"))
60
+
61
  @router.get("/health")
62
  def health() -> dict:
63
  return {
AIHealthcare/app/main.py CHANGED
@@ -36,9 +36,22 @@ app.add_middleware(
36
  allow_headers=["*"],
37
  )
38
 
39
- router = APIRouter(prefix="", tags=["triage"])
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  @router.get("/health")
43
  def health() -> dict:
44
  return {
 
36
  allow_headers=["*"],
37
  )
38
 
39
+ router = APIRouter(prefix="/triage", tags=["triage"])
40
 
41
 
42
+ @router.get("/")
43
+ def index() -> FileResponse:
44
+ """Serve the AI Healthcare page."""
45
+ base = os.path.dirname(__file__)
46
+ return FileResponse(os.path.join(base, "static", "index.html"))
47
+
48
+ # Add route without trailing slash for compatibility
49
+ @router.get("")
50
+ def index_no_slash() -> FileResponse:
51
+ """Serve the AI Healthcare page (no trailing slash)."""
52
+ base = os.path.dirname(__file__)
53
+ return FileResponse(os.path.join(base, "static", "index.html"))
54
+
55
  @router.get("/health")
56
  def health() -> dict:
57
  return {
server.py CHANGED
@@ -92,18 +92,30 @@ try:
92
  except Exception:
93
  pass
94
 
95
- # Mount apps with unprefixed routers under stable paths
96
- for mount_path, import_path in (
97
- ("/arch", "AIArchitecture.app.main"),
98
- ("/shop", "AICommerce.app.main"),
99
- ("/invoice", "AIAutomation.app.main"),
100
- ("/triage", "AIHealthcare.app.main"),
101
- ):
102
- try:
103
- sub = __import__(import_path, fromlist=["app"]) # type: ignore
104
- app.mount(mount_path, getattr(sub, "app")) # type: ignore
105
- except Exception:
106
- pass
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
 
109
  # --- Index routes for top-level and agent landings ---
 
92
  except Exception:
93
  pass
94
 
95
+ # Include routers with proper prefixes
96
+ try:
97
+ from AIArchitecture.app.main import router as arch_router # type: ignore
98
+ app.include_router(arch_router)
99
+ except Exception:
100
+ pass
101
+
102
+ try:
103
+ from AICommerce.app.main import router as commerce_router # type: ignore
104
+ app.include_router(commerce_router)
105
+ except Exception:
106
+ pass
107
+
108
+ try:
109
+ from AIAutomation.app.main import router as automation_router # type: ignore
110
+ app.include_router(automation_router)
111
+ except Exception:
112
+ pass
113
+
114
+ try:
115
+ from AIHealthcare.app.main import router as healthcare_router # type: ignore
116
+ app.include_router(healthcare_router)
117
+ except Exception:
118
+ pass
119
 
120
 
121
  # --- Index routes for top-level and agent landings ---