Skip to content

chungg/fullstack-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gate

flask + htmx + bulma

sample app which provides:

setup

  • install system requirements
    • debian/ubuntu - sudo apt install libpq-dev postgresql pipenv
  • 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>;

configuring

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

auth providers

todo how to set up external providers

managing

migrations

autogen migrations

  • ENV=local pipenv run flask --app app.app db migrate -m '' --directory app/storage/migrations

apply

  • ENV=local pipenv run flask --app app.app db upgrade --directory app/storage/migrations

init (if starting from scratch or you want to compress migrations)

  • ENV=local pipenv run flask --app app.app db init --directory app/storage/migrations

permissions

init

  • ENV=local pipenv run flask --app app.app roles create superuser
  • ENV=local pipenv run flask --app app.app users create -a

details

  • ENV=local pipenv run flask --app app.app show roles

running

server (locally)

  • ENV=local pipenv run flask --app app.app run --debug

server (container - locally)

  • podman build -f Dockerfile
  • podman run --network host -p 5000:5000 --env-file=.env flask --app app.app run --debug

client

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

running tests

  • pipenv install --dev

styling

  • pipenv run flake8
  • ./biome check app/static

unit

  • SQLALCHEMY_DATABASE_URI=<postgres_uri> pipenv run pytest tests/unit
  • see github actions workflow for sample

system

setup

  • pipenv run playwright install

run

  • ENV=local pipenv run flask --app app.app run
  • TEST_USER= TEST_PW= pipenv run pytest tests/system

debug

  • TEST_USER= TEST_PW= pipenv run pytest tests/system -k <test_case> --headed --slowmo 1000

resources

todo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published