http-exception
"/home/yossef/notes/full-stack/python-backend/fastapi//http-exception.md"
path: full-stack/python-backend/fastapi//http-exception.md
- **fileName**: http-exception
- **Created on**: 2025-03-15 01:22:56
from fastapi.exceptions import HTTPException
## now starting with the path param
@api.get("/todo/{todo_id}", response_model=Todo)
def get_todo(todo_id: int):
for todo in todo_user:
if todo.todo_id == todo_id:
return todo
# create a exception if error happend or not found
raise HTTPException(status_code=404, detail="not found todo")
for more information check
continue:./python-dotenv.md
before: ./fastapi-validation-schemes.md