Spaces:
Sleeping
Sleeping
File size: 1,316 Bytes
4d592a4 4ba4b25 4d592a4 4ba4b25 4d592a4 4ba4b25 4d592a4 4ba4b25 4d592a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from backend.app.api.v1.routes import router as api_router
from backend.app.config import settings
import os
app = FastAPI(
title="RAG System API",
description="Production-grade RAG system with PDF document processing and web search",
version="1.0.0",
docs_url="/api/docs",
redoc_url="/api/redoc",
)
app.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(api_router, prefix="/api/v1")
# Serve static files (React frontend)
frontend_path = os.path.join(os.path.dirname(__file__), "../../frontend/dist")
try:
if os.path.exists(frontend_path):
app.mount("/", StaticFiles(directory=frontend_path, html=True), name="static")
except Exception:
pass
@app.get("/")
async def serve_index():
index_path = os.path.join(frontend_path, "index.html")
if os.path.exists(index_path):
return FileResponse(index_path)
return {"message": "RAG System API", "version": "1.0.0"}
@app.get("/health")
async def health_check():
return {"status": "healthy", "service": "RAG System"}
|