pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
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.
19 lines
453 B
19 lines
453 B
from fastapi import APIRouter, FastAPI
|
|
|
|
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.")
|