Implementing the Falcon API
The structure of the Falcon project we're about to code is nowhere near as extended as the interface one. We'll code five files altogether. In your
ch12 folder, create a new one called
pwdapi. This is its final structure:
$ tree -A pwdapi/ pwdapi/ ├── core │ ├── handlers.py │ └── passwords.py ├── main.py └── tests └── test_core ├── test_handlers.py └── test_passwords.py
The API was all coded using TDD, so we're also going to explore the tests. However, I think it's going to be easier for you to understand the tests if you first see the code, so we're going to start with that.
The main application
This is the code for the Falcon application:
import falcon from core.handlers import ( PasswordValidatorHandler, ...