https://github.com/cosmicpython/book
https://github.com/cosmicpython/code
Examples have been refactored. Flask has been replaced with FastAPI. Asynchronous ORM has been used.
- docker with docker-compose
- for chapters 1 and 2, and optionally for the rest: a local python3.7 virtualenv
(this is only required from chapter 3 onwards)
make build
make up
# or
make all # builds, brings containers up, runs tests
python3.7 -m venv .venv
poetry install
poetry shell # or source .venv/bin/activate
make test
There are more useful commands in the makefile, have a look and try them out.
(since chapter 06)
poetry shell
cd <chapter folder>
export PYTHONPATH=$(pwd)/src:$(pwd)/tests
make postgres
uvicorn allocation.entrypoints.main:app --reload
pytest
(since chapter 06)
VS Code launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"allocation.entrypoints.main:app",
"--reload"
],
"jinja": true,
"justMyCode": true,
"env": {
"PYTHONPATH": "${cwd}/chapter_06_uow/src" // change to the selected chapter
}
}
]
}
Run a web-server locally.