52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""
|
|
Foxus Backend - Local AI Coding Assistant
|
|
Main FastAPI application entry point
|
|
"""
|
|
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.core.config import settings
|
|
from app.api import ai, files, models
|
|
|
|
# Create FastAPI app
|
|
app = FastAPI(
|
|
title="Foxus API",
|
|
description="Local AI Coding Assistant Backend",
|
|
version="1.0.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc"
|
|
)
|
|
|
|
# Add CORS middleware for frontend communication
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:1420", "https://tauri.localhost"], # Tauri default origins
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include API routes
|
|
app.include_router(ai.router, prefix="/api/ai", tags=["AI"])
|
|
app.include_router(files.router, prefix="/api/files", tags=["Files"])
|
|
app.include_router(models.router, prefix="/api/models", tags=["Models"])
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""Health check endpoint"""
|
|
return {"message": "Foxus API is running", "version": "1.0.0"}
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
"""Health check for monitoring"""
|
|
return {"status": "healthy", "service": "foxus-api"}
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(
|
|
"main:app",
|
|
host=settings.HOST,
|
|
port=settings.PORT,
|
|
reload=settings.DEBUG,
|
|
log_level="info"
|
|
) |