You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
471 B

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.")