feat: add API routers for network, tasks, calendar, and services
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,37 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from modules.config_manager import ConfigManager
|
||||
from modules.odoo_client import OdooClient
|
||||
|
||||
CONFIG_DIR = Path(__file__).parent / "config"
|
||||
|
||||
app_config = ConfigManager(
|
||||
settings_path=str(CONFIG_DIR / "settings.yaml"),
|
||||
services_path=str(CONFIG_DIR / "services.yaml"),
|
||||
)
|
||||
|
||||
settings = app_config.get_settings()
|
||||
odoo_settings = settings.get("odoo", {})
|
||||
|
||||
odoo_client = OdooClient(
|
||||
url=odoo_settings.get("url", "http://localhost:8069"),
|
||||
database=odoo_settings.get("database", "odoo"),
|
||||
username=odoo_settings.get("username", "admin"),
|
||||
password=odoo_settings.get("password", "admin"),
|
||||
)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Startup
|
||||
try:
|
||||
await odoo_client.authenticate()
|
||||
except Exception as e:
|
||||
print(f"Warning: Could not connect to Odoo: {e}")
|
||||
yield
|
||||
# Shutdown
|
||||
|
||||
|
||||
app = FastAPI(title="TV Dashboard API", lifespan=lifespan)
|
||||
@@ -19,7 +43,14 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
from routers import network, tasks, calendar, services
|
||||
|
||||
app.include_router(network.router)
|
||||
app.include_router(tasks.router)
|
||||
app.include_router(calendar.router)
|
||||
app.include_router(services.router)
|
||||
|
||||
|
||||
@app.get("/api/health")
|
||||
async def health():
|
||||
return {"status": "ok"}
|
||||
return {"status": "ok", "odoo_connected": odoo_client.uid is not None}
|
||||
|
||||
Reference in New Issue
Block a user