FastAPI mounted sub-applications
examples/fastapi/mounted-applications/main.py
import os from fastapi import FastAPI, Response from api_v1 import api_v1 root = os.path.dirname(os.path.abspath(__file__)) app = FastAPI() app.mount("/api/v1", api_v1) @app.get("/") async def main(): return Response(content='main <a href="/api/v1">/api/v1</a>', media_type="text/html")
examples/fastapi/mounted-applications/api_v1.py
from fastapi import FastAPI api_v1 = FastAPI() @api_v1.get("/") def main(): return {"message": "Hello World from API v1"}
uvicorn main:api_v1 --reload --host=0.0.0.0 uvicorn main:main --reload --host=0.0.0.0