Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Boiler Plate

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

Setup App

Run the following commands:

  • Ensure you have python installed(you could use any version)
  • Install pipenv via:
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-sample file to create a .env file 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')

Postman Docs

You can get the documentation for the api endpoints from the postman docs in the /docs folder

Setup app with Docker

  • 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>

Redis and Celery

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).

Starting Redis

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 redis

This 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

Starting Celery

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

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages