creativesar/face
0
1from fastapi import FastAPI, HTTPException, Request2from fastapi.middleware.cors import CORSMiddleware3from pydantic import BaseModel4import os5import logging6from dotenv import load_dotenv7 8# Load environment variables9load_dotenv()10 11# Import our API routes12from api.chat import router as chat_router13from api.content import router as content_router14from api.translate import router as translate_router15 16# Configure logging17logging.basicConfig(level=logging.INFO)18logger = logging.getLogger(__name__)19 20# Create FastAPI app21app = FastAPI(22 title="Physical AI & Humanoid Robotics Textbook API",23 description="Backend API for RAG chatbot and content services",24 version="1.0.0"25)26 27# Add CORS middleware28app.add_middleware(29 CORSMiddleware,30 allow_origins=["*"], # In production, replace with specific origins31 allow_credentials=True,32 allow_methods=["*"],33 allow_headers=["*"],34)35 36# Include API routers37app.include_router(chat_router, prefix="/api/chat", tags=["chat"])38app.include_router(content_router, prefix="/api/content", tags=["content"])39app.include_router(translate_router, prefix="/api/translate", tags=["translate"])40 41@app.get("/")42async def root():43 return {"message": "Physical AI & Humanoid Robotics Textbook API"}44 45@app.get("/health")46async def health_check():47 return {"status": "healthy"}48 49if __name__ == "__main__":50 import uvicorn51 uvicorn.run(52 "main:app",53 host="0.0.0.0",54 port=int(os.getenv("PORT", 8000)),55 reload=True56 )