File size: 398 Bytes
6822ffa
e953bef
360d6a0
e953bef
360d6a0
e953bef
 
6822ffa
e953bef
 
 
 
 
 
 
 
 
 
6822ffa
e953bef
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from fastapi import FastAPI
from celery import Celery

app = FastAPI()

BROKER_URL = 'redis://139.59.127.180:6379/0'
BACKEND_URL = 'redis://139.59.127.180:6379/0'

celery = Celery(
    __name__,
    broker=BROKER_URL,
    backend=BACKEND_URL
)


@app.get("/")
async def root():
    return {"message": "Hello World"}

@celery.task
def divide(x, y):
    import time
    time.sleep(5)
    return x / y