mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
508 stars 135 forks source link

Hello, how to use this parameter? "webhook_url": "" #253

Closed a88852asdw closed 2 months ago

a88852asdw commented 3 months ago

Hello, how to use this parameter? "webhook_url": ""

mrhan1993 commented 2 months ago

Start a server like this:

import uvicorn
from fastapi import FastAPI, Request

app = FastAPI()

@app.post("/task_result")
async def task_result(req: Request):
    received_data = await req.json()
    print(f"Received data: {received_data}")
    return received_data

uvicorn.run(app, host="0.0.0.0", port=8000)

start app with --webhook-url http://127.0.0.1:8000/task_result , and then, when a generation finished, server will received a json like:

{'job_id': '990cae4d-17a8-45b5-8086-a82ac4205ea7', 'job_result': [{'url': 'http://127.0.0.1:8888/files/2024-04-09/324eeded-95e6-4d2f-8e6e-69e00fd56be3.png', 'seed': '6289709461860950326'}]}

you can use --webhook-url to provide a global url, orspecify a different URL for each task through the webhook_url parameter in params