Flask app for the eODP API.
We are using Python 3.6.8 on the production server.
For the dev environment, we are using pyenv to run Python 3.6.8, pip to manage packages, and pyenv-virtualenv to manage virtual environments.
(1) Install pyenv, pyenv-virtualenv
(2) Install Python 3.6.8
pyenv install 3.6.8
set this directory to use Python 3.6.8
pyenv local 3.6.8
(3) Start virtual environment
create virtual environment
pyenv virtualenv 3.6.8 <venv-name>
set this directory to use <venv-name>
virtual environment
pyenv local <venv-name>
(4) Install packages.
pip install -r requirements.txt
(5) Config .env file
Copy .env-example
and rename it .env
.
Fill in the missing environmental variables.
(6) Install additional packages
pip install <package>
pip freeze > requirements.txt
Start Flask app. The app is set to run in debug mode for development.
python app/app.py
We are using flask-migrate to handle SQLAchemy migrations.
Make flask
available to the command line.
export FLASK_APP=app/app.py
Migration commands.
# create migration
flask db migrate -m 'name of migration'
# run migration
flask db upgrade
# undo migration
flask db downgrade
If flask command is not available, try:
python -m flask db migrate -m 'name of migration'
python -m flask db upgrade
NOTE: Running flask from the command using Python 3.6 might result in an ASCII encoding error with Click.
You can try:
# option 1
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
# option 2
unset LC_ALL
Scripts to import data are located in app/scripts
. We are using Fire to run the scripts.
python app/scripts/<file>.py <method>
Run tests
pytest
Run linter (flake8) and code formatter (Black).
python scripts/linter.py
We are using rsync to sync the files to the live server
./deploy.sh [email protected]