Spaces:
Running
Running
File size: 731 Bytes
ff6b176 bd469c1 ff6b176 bd469c1 ff6b176 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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()
|