Building a simple CRUD app
We have built routes for creating and retrieving todos. Let’s build the routes for updating and deleting the added todo. Let’s start by creating a model for the request body for the UPDATE route in model.py:
class TodoItem(BaseModel):
   item: str
   class Config:
       schema_extra = {
           "example": {
               "item": "Read the next chapter of the book"
           }
       }
Next, let’s write the route for updating a todo in todo.py:
from fastapi import APIRouter, Path
from model import Todo, TodoItem
todo_router = APIRouter()
todo_list = []
@todo_router.post("/todo")
async def add_todo(todo...