sipi-web/sipi-app/views/isp.py

40 lines
911 B
Python
Raw Permalink Normal View History

from starlette.requests import Request
from starlette.responses import HTMLResponse
from starlette.templating import Jinja2Templates
2024-07-14 18:37:00 +00:00
from typing import Annotated
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from models import db_helper
from crud import isp as isp_crud
from fastapi.encoders import jsonable_encoder
router = APIRouter(
2024-07-14 18:37:00 +00:00
tags=["Web"],
)
templates = Jinja2Templates(directory="views/templates")
2024-07-14 18:37:00 +00:00
@router.get("/get_all", response_class=HTMLResponse)
async def get_all_isp(
request: Request,
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
):
isps = jsonable_encoder(
await isp_crud.get_all_isp(
session=session,
)
)
print(isps)
return templates.TemplateResponse(
2024-07-14 18:37:00 +00:00
"body-isp.html",
{
"request": request,
2024-07-14 18:37:00 +00:00
"isps": isps,
},
)