This repository contains an example code which shows the integration between Flask, Socket.IO and Celery. The application is made in Flask where a counting task, representing a lengthy task, is performed by the celery worker. To update the client with the status of the task, Flask-SocketIO (by Miguel Grinberg) is used in the application to communicate with the celery task and report to the client.
- Clone this repository.
- Create a virtualenv.
- Install the requirements:
$ pip install -r requirements.txt
. - Open a second terminal window and start a local RabbitMQ server:
$ rabbitmq-server
. - Open a third terminal window and starta Celery worker:
$ venv/bin/celery worker -A app.celery --loglevel=info
. - Start the Flask application on your original terminal window:
$ venv/bin/python app.py
. - Finally, go to
http://localhost:5000/
.
Hope it is helpful!