When It Isn't There: HTTPException and 404

A FastAPI route answers 404 for an item that isn't there by raising HTTPException with a status code and a detail message, which stops the function at once and sends {"detail": ...}, and a route that creates something sets status_code=201 on its decorator.

By

Updated

Cheat sheet: When It Isn't There: HTTPException and 404
Category
FastAPI
Level
Apprentice
Tags
201 Created, 404 Not Found, fastapi, HTTPException, rest-api, Status Code in FastAPI