Flask RabbitMQ Celery example

If you are learning the way how to work with RABBITMQ + CELERY. This source code may help you. I wrote a small example to upload image to web server and use Celery to generate a thumbnail.

Difficult doesn’t mean impossible. It simply means that you have to work hard

This source code supports 2 ways to run it.

You can check the source code in Github: flask-celery-rabbitmq-generate-thumbnail

And the image at docker: flask-celery-rabbitmq-example

At the first, clone this source code to your local:

Using Docker

  1. Build from Dockerfile

Or pull from Docker Repo

Run Docker image

After running the docker image, you should wait for the output as below:

Install packets normally (Ubuntu 14.04)

I will show you how to run this source code from scratch. And i am using ubuntu server 14.04, installed virtualenv, pip.

Install RabbitMQ Server:

Fix the issue of PIL

Create environment to run the application with virtualenv:

Install all packets required:

Run web server to upload files

Run the “generate thumbnail” task in Celery

Now, it is ready for testing. (http://localhost:5000). The page should be as image below:

generate thumbnail with celery rabbitmq

Generate thumbnail with celery rabbitmq