Skip to content
Sharp

FastAPI · interview question

Which option is the safer default when shipping code around route handlers?

Multiple choiceHardchapter-13-curatedpremiumfastapiroute-handlers
python
from fastapi import FastAPI

app = FastAPI()

@app.get("/orders/{order_id}")
def get_order(order_id: str) -> dict[str, str]:
    return {"order_id": order_id}
Choose one answer
Answer and explanation

Correct answer

C. Choose the simpler shape that keeps the rule obvious, validated, and easy to observe in logs or tests.

Why

The safest default is usually the one that lowers ambiguity and makes errors easier to diagnose.

Test yourself on FastAPI

A free test with instant, explained results. No account needed.

Start free test
All FastAPI questions →