Complete the code to import FastAPI and create an app instance.
from fastapi import [1] app = [1]()
FastAPI is the main class to create the app instance.
Complete the code to import APIRouter and create a router instance.
from fastapi import [1] router = [1]()
APIRouter is used to create a router instance for grouping routes.
Fix the error in including the router in the main app.
app = FastAPI()
app.[1](router)The correct method to add a router to the app is include_router.
Fill both blanks to define a route in the router and include it in the app.
from fastapi import FastAPI, APIRouter router = APIRouter() @router.[1]("/") async def root(): return {"message": "Hello"} app = FastAPI() app.[2](router)
Use @router.get to define a GET route and app.include_router to add the router.
Fill all three blanks to create a router with a prefix and include it in the app.
from fastapi import FastAPI, APIRouter router = APIRouter(prefix=[1]) @router.get("/") async def read_items(): return {"items": []} app = FastAPI() app.[2](router, [3]="/items")
Set prefix="/api" when creating the router, include it with include_router, and specify prefix="/items" in include_router to override or add prefix.