sample app which provides:
- backend
- backend via apiflask
- db via sqlalchemy
- config management via dotenv
- security via flask-security-too
- admin views via flask-admin
- package management via pipenv
- cli via click and rich
- ui
- test
- runner via pytest
- code styles via flake8 and biome
- system testing via playwright
- ci via gitub actions
- install system requirements
- debian/ubuntu -
sudo apt install libpq-dev postgresql pipenv
- debian/ubuntu -
- install python reqs -
pipenv install
- configure db
sudo -u postgres psql
create database <dbname>;
create user <user> with encrypted password '<pw>';
grant all privileges on database <dbname> to <user>;
create schema <schema>;
grant all on schema <schema> to <user>;
config options can be found at app/config.py. at a minimum, the following options need to be set:
- SQLALCHEMY_DATABASE_URI
- SECRET_KEY (run
secrets.token_urlsafe()
if not sure) - SECURITY_PASSWORD_SALT (run
secrets.SystemRandom().getrandbits(128)
if not sure)
you will need to create and assign a superuser
role to the user to see model views in Admin
todo how to set up external providers
- ENV=local pipenv run flask --app app.app db migrate -m '' --directory app/storage/migrations
- ENV=local pipenv run flask --app app.app db upgrade --directory app/storage/migrations
- ENV=local pipenv run flask --app app.app db init --directory app/storage/migrations
- ENV=local pipenv run flask --app app.app roles create superuser
- ENV=local pipenv run flask --app app.app users create -a
- ENV=local pipenv run flask --app app.app show roles
- ENV=local pipenv run flask --app app.app run --debug
- podman build -f Dockerfile
- podman run --network host -p 5000:5000 --env-file=.env flask --app app.app run --debug
import requests
sess = requests.Session()
sess.post('http://127.0.0.1:5000/api/login',
data={'email':'<email>','password':'<pw>', 'remember': 'false'},
headers={"Content-Type": "application/x-www-form-urlencoded"})
# session should have cookie
sess.cookies
- pipenv install --dev
- pipenv run flake8
- ./biome check app/static
- SQLALCHEMY_DATABASE_URI=<postgres_uri> pipenv run pytest tests/unit
- see github actions workflow for sample
- pipenv run playwright install
- ENV=local pipenv run flask --app app.app run
- TEST_USER= TEST_PW= pipenv run pytest tests/system
- TEST_USER= TEST_PW= pipenv run pytest tests/system -k <test_case> --headed --slowmo 1000
- flask-security:
- flask deep dives (tbh, i didn't read/watch these but so i clear bookmarks):
- bulma
- chart options - https://www.monterail.com/blog/javascript-libraries-data-visualization
- alt reactive tables
- htmx
- js
- more frontend via htmx https://htmx.org/docs/
- customise bulma via https://bulma.io/documentation/customize/
- worker processes? via ?
- optimised ci via mergify
- https://unsuckjs.com/
- plugin lines disappear (probably because afterevent is drawn before rendering);