Skip to content
Dispatch Dispatch Dispatch

Flask

Dispatch requires an HTTP endpoint to communicate with your app via webhooks. If you’re using Flask, great news, because Dispatch has a built-in integration for it, which sets up this HTTP endpoint for you. Initialize a Dispatch class with a reference to a Flask instance and it’s done.

from flask import Flask
from dispatch.flask import Dispatch
app = Flask(__name__)
dispatch = Dispatch(app, endpoint="https://my-app.com")
@dispatch.function
def background_job():
print("I'm executed asynchronously in background")
@app.get("/")
def index():
background_job.dispatch()
return "OK"