This commit is contained in:
superobk
2024-03-27 15:06:30 +08:00
parent ec10081276
commit 0549a033e1
3 changed files with 11 additions and 10 deletions

View File

@ -11,10 +11,11 @@ blackbox_factory = BlackboxFactory()
@app.post("/")
async def blackbox(blackbox_name: Union[str, None] = None, request: Request = None):
print(blackbox_name)
if not blackbox_name:
return await JSONResponse(content={"error": "blackbox_name is required"}, status_code=status.HTTP_400_BAD_REQUEST)
try:
box = blackbox_factory.create_blackbox(blackbox_name, {})
box = blackbox_factory.create_blackbox(blackbox_name)
except ValueError:
return await JSONResponse(content={"error": "value error"}, status_code=status.HTTP_400_BAD_REQUEST)
return await box.fast_api_handler(request)