This flask app includes:
- REST api for todo crud service
- raw sql for resource persistence, to show low-level database initialization
- uses sqlite3 database, but can be swapped out for other relational databases
For a local development environment, use pyenv venv setup:
# create .python-version file with v3.10
pyenv shell 3.10
# venv is natively supported in python v3.4+
python -m venv venv
# activate venv:
source venv/bin/activate
# install pkgs
pip install -r requirements.txtRun local flask development server:
export FLASK_APP=rest
export FLASK_DEBUG=1
flask init-db
flask runNo need to re-run 'init-db' for successive runs unless a db reset is needed.
Run local flask shell:
FLASK_APP=rest FLASK_DEBUG=1 flask shellRun local gunicorn wsgi server:
SCRIPT_NAME=/todo-flask-rest \
gunicorn --bind :8000 -w 2 -t 2 --log-level=debug --access-logfile - --error-logfile - rest:appApp structure is based on: flaskr tutorial.
Project dependencies:
pyenv shell 3.10
python -m venv venv
source venv/bin/activate
pip install -U pip
pip install flask zipp black gunicorn
pip freeze > requirements.txt