1- from fastapi import APIRouter
1+ from fastapi import APIRouter , Body
22from repository .profile_repository import fetch_content_template , fetch_county , fetch_municipality , fetch_region
3- from services .content import build_content , build_template_tree
3+ from services .content import build_content , build_single_content , build_template_tree
44from fastapi .responses import HTMLResponse
55from fastapi .staticfiles import StaticFiles
6- from fastapi .templating import Jinja2Templates
76
87router = APIRouter (
98 prefix = "/content" ,
1413# profile = build_tract_profile(geoid)
1514# return profile
1615
17- templates = Jinja2Templates (directory = "content" )
1816
1917
2018@router .get ("/municipality/{geoid}" )
@@ -37,6 +35,13 @@ async def get_region():
3735 content = await build_content ('region' , profile )
3836 return content
3937
38+ @router .post ('/preview' )
39+ async def get_content_template (category : str , subcategory : str , topic : str , body : str = Body (..., media_type = "text/plain" )):
40+ profile = await fetch_region ()
41+
42+ template = await build_single_content (body , profile ,category , subcategory , topic )
43+ return template
44+
4045@router .get ('/template/{geo_level}' )
4146async def get_content_template (geo_level : str , category : str , subcategory : str , topic : str ):
4247 template = await fetch_content_template (geo_level , category , subcategory , topic )
0 commit comments