mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-14 17:13:25 +00:00
doc: update swagger
This commit is contained in:
@ -1,27 +0,0 @@
|
||||
from typing import Any, Coroutine
|
||||
|
||||
from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
|
||||
|
||||
class SUM(Blackbox):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.processing(*args, **kwargs)
|
||||
|
||||
def valid(self, *args, **kwargs) -> bool:
|
||||
data = args[0]
|
||||
return isinstance(data, list)
|
||||
|
||||
def processing(self, *args, **kwargs):
|
||||
return sum(args)
|
||||
|
||||
async def fast_api_handler(self, request: Request) -> Response:
|
||||
try:
|
||||
data = await request.json()
|
||||
except:
|
||||
return JSONResponse(content={"error": "json parse error"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
if not self.valid(data):
|
||||
return JSONResponse(content={"error": "format error"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
return JSONResponse(content={"result": self.processing(data)}, status_code=status.HTTP_200_OK)
|
||||
Reference in New Issue
Block a user