1 changed files with 20 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||||
|
from fastapi import FastAPI, APIRouter |
||||
|
from fastapi.testclient import TestClient |
||||
|
|
||||
|
app = FastAPI() |
||||
|
api_router = APIRouter(prefix="/api") |
||||
|
|
||||
|
@api_router.get("/app") |
||||
|
def read_main(): |
||||
|
return {"message": "Hello World from main app"} |
||||
|
|
||||
|
subapi = FastAPI() |
||||
|
|
||||
|
@subapi.get("/sub") |
||||
|
def read_sub(): |
||||
|
return {"message": "Hello World from sub API"} |
||||
|
|
||||
|
api_router.mount("/subapi", subapi) # ← moved up |
||||
|
app.include_router(api_router) # ← now after |
||||
|
|
||||
|
print("All tests passed.") |
||||
Loading…
Reference in new issue