from fastapi import APIRouter , Request ,HTTPException from controllers import gmail_controller router = APIRouter(prefix="/process") @router.post("/receipt_data/direct") async def get_data(request:Request): try: body_data = await request.json() token = body_data.get('data') user_str = body_data.get('brand_name') if token is None: return HTTPException(status_code=400,detail="Token Invalid!") if user_str is None: user_str = None fetch_data = gmail_controller.GmailDataExtractor(token , user_str).extract_messages() return fetch_data except Exception as e: raise HTTPException(status_code=500, detail=str(e))