Complete the code to import APIRouter from FastAPI.
from fastapi import [1]
You import APIRouter from FastAPI to create modular route groups.
Complete the code to create a new APIRouter instance.
router = [1]()You create a router by calling APIRouter().
Fix the error in the route decorator to use the router instead of app.
@[1].get("/items") async def read_items(): return [{"item_id": "foo"}]
Routes in modular files use the router instance, not the main app.
Fill both blanks to include the router in the main FastAPI app.
from fastapi import FastAPI app = FastAPI() app.[1](router, prefix=[2])
You add modular routes to the main app using include_router with a prefix path.
Fill all three blanks to define a router with a GET route and include it in the app with prefix.
from fastapi import FastAPI, [1] router = [1]() @router.get("/hello") async def say_hello(): return {"message": "Hello"} app = FastAPI() app.[2](router, prefix=[3])
This shows the full pattern: import APIRouter, create router, define route, then include router in app with prefix.
