This project is an example of using Flask-restful and celery to perform asynchronous tasks.
Note : The installation into a virtualenv is heavily recommended.
If you want to install the package :
pip install .
For development purposes, you can install the package in editable mode with the dev requirements.
pip install -e . -r requirements-dev.txt
To start the application, you can use the file run.py :
python run.py
Moreover, to be able to play with celery, you have to first start Redis, then start a celery worker like this :
celery -A run.celery worker --loglevel=info
Note : It's cleaner to use docker-compose to start the whole application (see the section below).
In order to start the whole system easily, we can use docker-compose :
docker-compose up
It will start three docker containers :
- Redis
- Flask API
- Celery Worker
Then, you can access to the API in localhost :
curl -X GET -H "Content-Type: application/json" localhost:5000/api/bye/test
You can check the syntax using flake8 (you must have flake8 package installed first) :
flake8 api
You can also use tox (you must have tox package installed first) :
tox -e lint
To execute the test coverage, you must install the package with the dev requirements (see installation section).
You can run the coverage with the following command :
coverage run --source api -m py.test
You can also use tox (you must have tox package installed first) :
tox -e test