codejump

Routes & Request Validation

Preview — 3 of 10 questions

Which decorator registers a handler for GET /items?

A@app.get("/items")
B@app.route.get("/items")
C@app.fetch("/items")
D@FastAPI.get("/items")

What does this endpoint read from /items/7?

javascript
@app.get("/items/{item_id}")
def read_item(item_id: int):
    return {"item_id": item_id}
AThe string "7" without validation
BThe integer 7
CA query parameter named item_id
DA JSON body containing item_id

For GET /items?limit=5, where does limit come from in this route?

javascript
@app.get("/items")
def list_items(limit: int = 10):
    return {"limit": limit}
AA path parameter
BA request header
CA query parameter
DA JSON body

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.