Let’s get CRUDdier and then get testier!
Right now, the only thing in our app is two pre-generated endpoints. Let’s add some more to make this a little more interesting. We’re going to make a fake list app as we did in Chapter 8, Building a Dynamic Web Application with Flask.
Open up main.py
and let’s add one endpoint for each CRUD operation, and in turn, each of the four main methods used in building RESTful APIs. We’re going to make some sweeping changes, so I’ll simply present them starting at the top of the file.
On the first line, where we have the import, change it to this:
from fastapi import FastAPI, status, HTTPException app = FastAPI()
The app instantiate was unchanged. Below it, though, add this list of amazing people:
names = ["Bruce", "Karina", "Kitty", "Phoebe"]
This list will serve as a fake database, saving us the time of setting up servers and the blah blah blah, which...