Base project to work with the Python Flask framework in an easy way.
Create an .env
file in the root of the project with this information.
FLASK_APP_NAME=flask_base
MYSQL_HOSTNAME=db
MYSQL_DATABASE=flask_base_db
MYSQL_USER=flask_base_user
MYSQL_PASSWORD=flask_base_pass
MYSQL_ROOT_PASSWORD=flask_base_root_pass
To deploy the software under development environment, run:
docker compose -f docker-compose.dev.yml up -d
This will apply the migrations to the database and run the Flask application. Open http://localhost
to play with your fantastic app!
However, if during development there are new changes in the model, run inside the web
container:
flask db migrate
flask db upgrade
To run unit test, please enter inside web
container:
pytest app/tests/units.py
docker compose -f docker-compose.prod.yml up -d
To generate a new certificate, run in deploy server:
chmod +x ssl_setup.sh && ./ssl_setup.sh
To renew a certificate that is less than 60 days from expiry, execute in deploy server:
chmod +x ssl_renew.sh && ./ssl_renew.sh
To update all project dependencies automatically, run:
chmod +x update_dependencies.sh && ./update_dependencies.sh
Note: it is the responsibility of the developer to check that the update of the dependencies has not broken any functionality and each dependency maintains backwards compatibility. Use the script with care!
To add a new module or functionality to the project, an automatic script is provided:
python new_module.py
This will create a folder in app
with the name of the module and a file and directory structure according to the project.