18 lines
813 B
Python
18 lines
813 B
Python
from fastapi import APIRouter, Depends, Path
|
|
from fastapi.responses import HTMLResponse
|
|
|
|
from common.enums import ErrorType
|
|
from services.seo_service import SeoService
|
|
|
|
router = APIRouter(prefix="/v1/seo", tags=["seo"])
|
|
|
|
_SLUG = r"^[a-z]+$"
|
|
|
|
|
|
@router.get("/today/{sido}/{place}", response_class=HTMLResponse, summary="지역 검색 페이지: 정적 HTML 에 오늘 날씨·각을 채워 돌려준다 (nginx 가 /today/... 를 넘김)")
|
|
async def get_today_page(sido: str = Path(..., pattern=_SLUG), place: str = Path(..., pattern=_SLUG), service: SeoService = Depends()) -> HTMLResponse:
|
|
err, html = await service.page(f"today/{sido}/{place}")
|
|
if err is not ErrorType.SUCCESS:
|
|
return HTMLResponse("not found", status_code=404)
|
|
return HTMLResponse(html, headers={"Cache-Control": "no-cache"})
|