From 0f1f0874d35bcad655325d01ce06b9dfe4e35117 Mon Sep 17 00:00:00 2001 From: bro-maanii Date: Tue, 25 Jun 2024 11:16:18 +0500 Subject: [PATCH] PhoneCode --- src/routes/geo/country.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/routes/geo/country.py b/src/routes/geo/country.py index 065f6f2..34e6f99 100644 --- a/src/routes/geo/country.py +++ b/src/routes/geo/country.py @@ -58,3 +58,16 @@ async def get_country_subdivisions(data: CountryCodeModel = Depends()): return ok_200(res) except Exception as e: raise internal_error_500() + +@country_router.get("/phonecodes") +async def get_country_phonecodes(data: CountryCodeModel = Depends()): + try: + res = co.code_to_phone_code(data.code) + if res: + return ok_200(res) + else: + return not_found_404("Phone code not found for the given country code.") + except KeyError: + return bad_request_400("Invalid country code provided.") + except Exception as e: + return internal_error_500(str(e))