malepati/custom_template_working
0
1import aiohttp2from fastapi import HTTPException3from models.presentation_layout import PresentationLayoutModel4from typing import List5 6async def get_layout_by_name(layout_name: str) -> PresentationLayoutModel:7 url = f"http://localhost/api/template?group={layout_name}"8 async with aiohttp.ClientSession() as session:9 async with session.get(url) as response:10 if response.status != 200:11 error_text = await response.text()12 raise HTTPException(13 status_code=404,14 detail=f"Template '{layout_name}' not found: {error_text}"15 )16 layout_json = await response.json()17 # Parse the JSON into your Pydantic model18 return PresentationLayoutModel(**layout_json)19 