Update api.py
Browse files
api.py
CHANGED
|
@@ -1,42 +1,82 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
from fastapi
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
from storage
|
| 8 |
-
from storage.
|
| 9 |
-
from storage.
|
| 10 |
-
from
|
| 11 |
-
from
|
| 12 |
-
from
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
from
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
app
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
# FastAPI core imports
|
| 4 |
+
from fastapi import FastAPI
|
| 5 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
+
|
| 7 |
+
# Routers from storage module
|
| 8 |
+
from storage.media_routers import router as media_router
|
| 9 |
+
from storage.db_routers import router as db_router
|
| 10 |
+
from storage.embeddings_routers import router as embeddings_router
|
| 11 |
+
from storage.pending_videos_routers import router as pending_videos_router
|
| 12 |
+
from storage.data_routers import router as data_router
|
| 13 |
+
|
| 14 |
+
# Routers from main process module
|
| 15 |
+
from main_process.main_router import router as main_router
|
| 16 |
+
from main_process.salamandra_router import router as salamandra_router
|
| 17 |
+
from main_process.moe_router import router as moe_router
|
| 18 |
+
from main_process.refinement_router import router as refinement_router
|
| 19 |
+
|
| 20 |
+
# Preprocessing router
|
| 21 |
+
from preprocessing_router import router as preprocessing_router
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# ---------------------------------------------------------
|
| 25 |
+
# FastAPI Application Initialization
|
| 26 |
+
# ---------------------------------------------------------
|
| 27 |
+
|
| 28 |
+
app = FastAPI(
|
| 29 |
+
title="Veureu Engine API",
|
| 30 |
+
version="0.2.0",
|
| 31 |
+
description="API providing access to Veureu Engine services."
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# ---------------------------------------------------------
|
| 36 |
+
# CORS Configuration
|
| 37 |
+
# ---------------------------------------------------------
|
| 38 |
+
|
| 39 |
+
# Allow all origins for now — adjust for production environments
|
| 40 |
+
app.add_middleware(
|
| 41 |
+
CORSMiddleware,
|
| 42 |
+
allow_origins=["*"], # Allows requests from any origin
|
| 43 |
+
allow_credentials=True,
|
| 44 |
+
allow_methods=["*"], # Allows all HTTP methods
|
| 45 |
+
allow_headers=["*"], # Allows all HTTP headers
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# ---------------------------------------------------------
|
| 50 |
+
# Router Registration
|
| 51 |
+
# ---------------------------------------------------------
|
| 52 |
+
|
| 53 |
+
# Storage-related routers
|
| 54 |
+
app.include_router(data_router)
|
| 55 |
+
app.include_router(media_router)
|
| 56 |
+
app.include_router(db_router)
|
| 57 |
+
app.include_router(embeddings_router)
|
| 58 |
+
app.include_router(pending_videos_router)
|
| 59 |
+
|
| 60 |
+
# Main process routers
|
| 61 |
+
app.include_router(main_router)
|
| 62 |
+
app.include_router(salamandra_router)
|
| 63 |
+
app.include_router(moe_router)
|
| 64 |
+
app.include_router(refinement_router)
|
| 65 |
+
|
| 66 |
+
# Preprocessing router with prefix
|
| 67 |
+
app.include_router(preprocessing_router, prefix="/preprocessing")
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# ---------------------------------------------------------
|
| 71 |
+
# Root Endpoint
|
| 72 |
+
# ---------------------------------------------------------
|
| 73 |
+
|
| 74 |
+
@app.get("/", summary="Root endpoint", tags=["health"])
|
| 75 |
+
def root():
|
| 76 |
+
"""
|
| 77 |
+
Root health-check endpoint.
|
| 78 |
+
|
| 79 |
+
Returns:
|
| 80 |
+
dict: A minimal JSON response indicating that the service is running.
|
| 81 |
+
"""
|
| 82 |
+
return {"ok": True, "service": "veureu-engine"}
|