This is a boiler plate for flask that has the following configured:
- redis
- celery
- models and migrations
- sendgrid
- testing
It also has the following endpoints implemented:
- signup: POST /api/auth/register
- login: POST /api/auth/login
- forgotPassword: POST /api/auth/forgot-password
Run the following commands:
- Ensure you have python installed(you could use any version)
- Install
pipenvvia:
pip install pipenv- Clone repo via:
git clone <repo-url>- Start virtual environment via:
pipenv shell --python "<your-python-version>"- Install dependencies via:
pipenv install- Make bash scripts executable via:
chmod +x scripts/install_hooks.sh scripts/pre_commit.sh scripts/install_commit_template.sh- Install hooks by running:
scripts/install_hooks.sh- Install Git commit template by running:
scripts/install_commit_template.sh-
Use the
.env-samplefile to create a.envfile with required environmental variables -
Generate migration
flask db migrate -m <name_of_migration>- Run migrations
flask db upgrade- Run lint manually
yapf -ir $(find . -name '*.py')You can get the documentation for the api endpoints from the postman docs in the /docs folder
-
Ensure you have Docker for mac installed and running on your machine
-
Build and tag the docker image
docker build -t <tag> -f Docker/Dockerfile .- Spin up the container
docker run -d --name <container name> --env FLASK_ENV='<environment>' --env DATABASE_URL='<database url>' -p 5000:5000 <tag>:latest- The above command should return a container ID, to stop a running container
docker stop <containerID>OR
docker stop <container name>Celery is used as the message broker for the API. We use it to run heavy task(via celery-workers) and run cron-jobs(via celery-beat).
In order to run celery, you would need to ensure that a redis is running.
Using docker, you can achieve this by running
docker run -p 6379:6379 redisThis would spin up a redis server in port 6379 in your machine.
If your redis server is running on a different port/host, you must specify the URL in the .env file via key REDIS_SERVER_URL
Once Redis is up and running, you can now spin up celery in these steps:
- Start celery worker by executing
celery -A celery_config.celery_app worker --loglevel=info- In a separate terminal, spin up the celery beat via