Structuring in FastAPI applications
For this chapter, we’ll be building an event planner. Let’s design the application structure to look like this:
planner/   main.py   database/     __init__.py     connection.py   routes/     __init__.py     events.py     users.py   models/     __init__.py     events.py     users.py
The first step is to create a new folder for the application. It will be named planner
:
$ mkdir planner && cd planner
In the newly created planner
folder, create an entry file, main.py
, and three subfolders – database
, routes
, and models
:
$ touch main.py $ mkdir database routes models
Next, create __init__.py
in every folder:
$ touch {database,routes,models}/__init__.py
In the database
folder, let’s create a blank...