I am trying to make a task with celery using redis as broker and backend with fastapi.

I am new to this so I do not know what am I doing wrong.

I am following this tutorial: <https://www.youtube.com/watch?v=mcX_4EvYka4>

I am also giving my own code below:

**.env**

```
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0

```

**celery\_worker.py**

```py
import os
import time

from celery import Celery
from dotenv import load_dotenv

load_dotenv()

celery = Celery(__name__)
celery.conf.broker_url = os.environ.get("CELERY_BROKER_URL")
celery.conf.result_backend = os.environ.get("CELERY_RESULT_BACKEND")

@celery.task(name="create_task")
def create_tasks(a, b, c):
    print(a, b, c)
    time.sleep(a)
    return b + c

```

**app.py**

```py
from fastapi import FastAPI, Body

# Initializes FastAPI
app = FastAPI()

from celery_worker import create_tasks
from fastapi.responses import JSONResponse

@app.post("/test")
def run_task(data=Body(...)):
    amount = int(data["amount"])
    x = int(data["x"])
    y = int(data["y"])
    task = create_tasks.delay(amount, x, y)
    return JSONResponse({"Result": task.get()})

```

I am using `flower` to view the tasks in the browser.

When I am excecuting the `/test` endpoint a task is created. But it is not excecuting.

[![enter image description here](https://i.stack.imgur.com/1fSL7.png)](https://i.stack.imgur.com/1fSL7.png)

The command I am using to run celery and flower is below:

```
celery -A celery_worker.celery worker --loglevel=INFO

```

```
celery -A celery_worker.celery flower --port=5555

```

What could be the problem here?

Thanks