yokonsan / midjourney-api

midjourney in discord api.
777 stars 176 forks source link

🐛 callback api接口有没有示例 #59

Closed yimengqiangu closed 1 year ago

yimengqiangu commented 1 year ago

问题简述

我配置CALLBACK_URL=http://127.0.0.1:8000/callback,它没有被调用 from fastapi import FastAPI from typing import List, TypedDict

app = FastAPI()

class Attachment(TypedDict): id: int url: str proxy_url: str filename: str content_type: str width: int height: int size: int ephemeral: bool

class EmbedsImage(TypedDict): url: str proxy_url: str

class Embed(TypedDict): type: str description: str image: EmbedsImage

class CallbackData(TypedDict): type: str id: int content: str attachments: List[Attachment] embeds: List[Embed] trigger_id: str

@app.post("/callback") async def callback(callback_data: CallbackData):

在这里可以访问解析后的参数

# callback_data.type
# callback_data.id
# callback_data.content
# callback_data.attachments
# callback_data.embeds
# callback_data.trigger_id

# 在这里进行处理和逻辑操作

return {"message": "Callback received"}

if name == "main": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000)

复现方式

执行以上代码

环境信息

额外信息

No response

一点点的自我检查

liuyuaaa commented 12 months ago

解决了吗,问下怎么操作的