refactor: 更新API路由参数解析,使用Body获取请求数据,简化请求处理逻辑
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import json
|
||||
from typing import Optional
|
||||
from typing import Dict, Optional
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
from fastapi import APIRouter, Body, HTTPException, Request
|
||||
from fastapi.openapi.models import RequestBody
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from workflow_service import comfyui_client, database
|
||||
@@ -14,15 +15,15 @@ run_router = APIRouter(
|
||||
|
||||
@run_router.post("")
|
||||
async def run_workflow(
|
||||
request: Request, workflow_name: str, workflow_version: Optional[str] = None
|
||||
workflow_name: str,
|
||||
workflow_version: Optional[str] = None,
|
||||
data: Dict = Body(...),
|
||||
):
|
||||
"""
|
||||
异步执行工作流。
|
||||
立即返回任务ID,调用者可以通过任务ID查询执行状态。
|
||||
"""
|
||||
try:
|
||||
data = await request.json()
|
||||
|
||||
if not workflow_name:
|
||||
raise HTTPException(status_code=400, detail="`workflow_name` 字段是必需的")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user