demo version prepped
This commit is contained in:
32
backend/api/v1/cellsites/__init__.py
Normal file
32
backend/api/v1/cellsites/__init__.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from fastapi import APIRouter
|
||||
import database as db
|
||||
from typing import Any
|
||||
from logger import get_logger
|
||||
logger = get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/cellsites", tags=["cellsites"])
|
||||
|
||||
@router.get("/")
|
||||
def get_cellsites() -> list[dict[Any, Any]]: # type: ignore
|
||||
conn = db.connect_to_db()
|
||||
try:
|
||||
with db.connect_to_db() as conn:
|
||||
return db.get_cellsites(conn)
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching cellsites: {e}", exc_info=True)
|
||||
return []
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
@router.get("/{id}")
|
||||
def get_cellsite(id: int) -> list[dict[str, Any]]: # type: ignore
|
||||
conn = db.connect_to_db()
|
||||
try:
|
||||
with db.connect_to_db() as conn:
|
||||
return db.get_cellsite(conn, id)
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching cellsite {id}: {e}", exc_info=True)
|
||||
return []
|
||||
finally:
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user