llm-ready-data / app /api /verify.py
Soumik Bose
optimization 404
bd469c1
Raw
History Blame Contribute Delete
731 Bytes
from __future__ import annotations
from fastapi import APIRouter, HTTPException, Query
from app.core.thread_pool import run_in_executor
from app.services.verify_service import VerifyService
router = APIRouter(tags=["Verify"])
_service = VerifyService()
@router.get("/phone")
async def verify_phone(
number: str = Query(..., description="Phone number (E.164 format like +14155552671, or local with country_code)"),
country_code: str | None = Query(None, description="ISO 3166-1 alpha-2 country code (e.g. US, IN, GB)"),
):
result = await run_in_executor(_service.verify_phone, number, country_code)
if not result.valid:
raise HTTPException(status_code=400, detail=result.error)
return result.dict()