FastAPI app.py
files can get long. Use APIRouter
to structure the application into different files. In api/elsewhere.py
,
router = APIRouter(prefix="/elsewhere")
@router.get("/somewhere/")
def func():
pass
and then in app.py
from .api import elsewhere
app = FastAPI()
app.include_router(elsewhere.router)