Spaces:
Building
Building
File size: 2,143 Bytes
6d01d5b 08d7c19 6d01d5b 3f8cf16 6d01d5b e27e999 992bd88 2454b0a 08d7c19 6d01d5b 08d7c19 6d01d5b e27e999 992bd88 e27e999 6d01d5b 08d7c19 6d01d5b 08d7c19 3f8cf16 6d01d5b |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import logging
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
from app.database import init_db # Import init_db
from app.auth import router as auth_router
from app.upload import router as upload_router
from app.dashboard import router as dashboard_router
from app.agent.custom_chatbot import router as custom_chatbot_router
from app.feeds import router as feeds_router
# from app.routes import pdf_ingestions
# Initialize logger
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
app = FastAPI(
title="Dubsway Video AI",
description="Production-ready API for auth, video upload, and analysis with Groq LLM integration",
version="1.0.0",
docs_url="/docs", # Optional: secure this in prod
redoc_url=None,
)
# Allow frontend (adjust in prod!)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # REPLACE with frontend URL in production!
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include API routes
app.include_router(auth_router, prefix="/api", tags=["Auth"])
app.include_router(upload_router, prefix="/api", tags=["Upload"])
app.include_router(dashboard_router, prefix="/api", tags=["Dashboard"])
app.include_router(custom_chatbot_router, prefix="/api", tags=["Custom Chatbot"])
app.include_router(feeds_router, prefix="/api", tags=["Feeds"])
# app.include_router(pdf_ingestion.router, prefix="/api", tags=["PDF Ingestion"])
@app.get("/")
async def root():
"""Root endpoint for Hugging Face Spaces"""
return {
"message": "π₯ Dubsway Video AI API",
"version": "1.0.0",
"docs": "/docs",
"status": "running"
}
@app.on_event("startup")
async def startup_event():
logger.info("β
FastAPI app started")
logger.info(f"Environment: {os.getenv('ENVIRONMENT', 'development')}")
logger.info(f"Database URL configured: {'DATABASE_URL' in os.environ}")
await init_db()
@app.on_event("shutdown")
async def shutdown_event():
logger.info("π FastAPI app shutdown")
|