22. Handy Commands

CLI snippets for local dev, profiling, and deployments.

# Virtualenv & upgrades
python3 -m venv .venv && source .venv/bin/activate
python -m pip install --upgrade pip

# Lint/format/type/test
ruff check . && ruff format .
mypy --strict .
pytest -q
pytest -m "slow" -q

# ASGI app
uvicorn app:app --host 0.0.0.0 --port 8080
# Production HTTP server
gunicorn -k uvicorn.workers.UvicornWorker app:app -w 4 -b 0.0.0.0:8080

# Profiling
python -m cProfile -o prof.out app.py && python -m pip install snakeviz && snakeviz prof.out

# Alembic migrations
alembic revision -m "feat: add index"
alembic upgrade head