mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
29 lines
932 B
Python
29 lines
932 B
Python
from typing import Union
|
|
|
|
from fastapi import FastAPI, Request, status
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from src.blackbox.blackbox_factory import BlackboxFactory
|
|
import uvicorn
|
|
|
|
app = FastAPI()
|
|
|
|
blackbox_factory = BlackboxFactory()
|
|
|
|
@app.post("/")
|
|
async def blackbox(blackbox_name: Union[str, None] = None, request: Request = None):
|
|
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)
|
|
except ValueError:
|
|
return await JSONResponse(content={"error": "value error"}, status_code=status.HTTP_400_BAD_REQUEST)
|
|
return await box.fast_api_handler(request)
|
|
|
|
@app.post("/workflows")
|
|
async def workflows(reqest: Request):
|
|
print("workflows")
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="127.0.0.1", port=8000, log_level="info")
|