0%

Flask

For develop some internal tools.

reference docs

pyvenv

Recommend to use pyvenv to develop flask, easy to manage the python version and packages

1
2
3
python3 -m venv /path/to/new/virtual/environment

source /path/to/new/virtual/environment

install flask

1
2
3
4
5
6
7
8
# under virtual env
pip install Flask

pip install flask-appbuilder

flask fab create-app

flask run

SQLAlchemy

Sometimes, if it’s not easy to add constriant condition on model.py in database level, we can try from application level by built-in methods pre_add https://flask-appbuilder.readthedocs.io/en/latest/api.html#flask_appbuilder.baseviews.BaseCRUDView.pre_add

security

Put sensitive data in file .env

1
SECRET_KEY=secret key

Use os module method getenv()

1
2
3
import os

secret_key = os.getenv("SECRET_KEY","default value")

issue