Complete the code to import FastAPI correctly.
from fastapi import [1]
FastAPI is imported from the fastapi package using FastAPI.
Complete the code to create a FastAPI app instance.
app = [1]()You create a FastAPI app by calling FastAPI().
Fix the error in the route decorator to define a GET endpoint.
@app.[1]("/") def read_root(): return {"message": "Hello World"}
The GET method is used to define a route that responds to HTTP GET requests.
Fill both blanks to create a path parameter and return it in the response.
@app.get("/items/[1]") async def read_item([2]: int): return {"item_id": [2]
The path parameter name in the route and the function argument must match exactly.
Fill all three blanks to create a POST endpoint that accepts a JSON body with a Pydantic model.
from pydantic import BaseModel class Item(BaseModel): name: str price: float @app.post("/items/") async def create_item([1]: [2]): return {"item_name": [3].name, "item_price": [3].price}
The function parameter name (e.g., item) and its type (Item) must match the Pydantic model. The parameter is used to access the data.
