Conventions used
There are a number of text conventions used throughout this book.
Code in text
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Obviously, if everything is okay, we get a Person
instance and have access to the properly parsed fields.”
A block of code is set as follows:
from fastapi import FastAPIapp = FastAPI() @app.get("/users/{type}/{id}") async def get_user(type: str, id: int): return {"type": type, "id": id}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
class PostBase(BaseModel): title: str content: str def excerpt(self) -> str: return f"{self.content[:140]}..."
Any command-line input or output is written as follows:
$ http http://localhost:8000/users/abcHTTP/1.1 422 Unprocessable Entity content-length: 99 content-type: application/json date: Thu, 10 Nov 2022 08:22:35 GMT server: uvicorn
Tips or important notes
Appear like this.