File size: 1,067 Bytes
d8e039b 6a50e97 d8e039b |
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 |
"""
Main FastAPI application
"""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from .api.routes import router
from .config import CORS_ORIGINS, ASSETS_DIR, FRONTEND_DIST_DIR
def create_app() -> FastAPI:
"""Create and configure the FastAPI application"""
app = FastAPI(title="Edge LLM API")
# Enable CORS for Hugging Face Space
app.add_middleware(
CORSMiddleware,
allow_origins=CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Mount static files
app.mount("/assets", StaticFiles(directory=ASSETS_DIR), name="assets")
# Include API routes
app.include_router(router)
@app.on_event("startup")
async def startup_event():
"""Startup event - don't load models by default"""
print("π Edge LLM API is starting up...")
print("π‘ Models will be loaded on demand")
return app
# Create the app instance
app = create_app()
|