File size: 458 Bytes
5b8169f
 
 
 
 
 
 
714bcf5
5b8169f
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import json
from fastapi import APIRouter
from fastapi.responses import JSONResponse
from components.gateways.headlines_to_wa import fetch_cached_headlines, send_to_whatsapp

router = APIRouter()

@router.get("/wa-headlines")
def send_digest():
    message = fetch_cached_headlines()
    if not message:
        return JSONResponse(status_code=404, content={"error": "No digest found in cache."})
    
    result = send_to_whatsapp(message)
    return result