agent-browser / app /main.py
anileo1's picture
Add agentic web browser app and frontend
78bccb2
Raw
History Blame Contribute Delete
849 Bytes
from contextlib import asynccontextmanager
from pathlib import Path
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from app.api.routes import router
from app.core.config import settings
from app.core.db import close_connection, get_connection
STATIC_DIR = Path(__file__).parent.parent / "frontend"
@asynccontextmanager
async def lifespan(app: FastAPI):
get_connection()
yield
close_connection()
app = FastAPI(title=settings.app_name, debug=settings.debug, lifespan=lifespan)
app.include_router(router, prefix="/api")
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
@app.get("/health")
async def health() -> dict[str, str]:
return {"status": "ok"}
@app.get("/")
async def index():
return FileResponse(STATIC_DIR / "index.html")