Skip to content

Commit 6468955

Browse files
Enhance : search Ignore if tm request fails
1 parent f6212e9 commit 6468955

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

api/views.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Provides classes for handling API requests."""
2+
23
# -*- coding: utf-8 -*-
34
from distutils.util import strtobool
45
import itertools
@@ -647,9 +648,7 @@ def request_geonames(request):
647648
"bbox": geojson,
648649
"adminName2": f'ISO3 : {feature["properties"]["iso_3"]}',
649650
"name": request.GET.get("q"),
650-
"countryName": feature["properties"][
651-
"name"
652-
],
651+
"countryName": feature["properties"]["name"],
653652
"adminName1": feature["properties"]["cid"],
654653
}
655654

@@ -697,7 +696,10 @@ def request_geonames(request):
697696
if len(lst) >= 1:
698697
keyword = lst[1]
699698
if tm_url:
700-
tm_res = requests.get(f"{tm_url}/{int(keyword)}/")
699+
try:
700+
tm_res = requests.get(f"{tm_url}/{int(keyword)}/")
701+
except Exception as ex:
702+
pass
701703
if tm_res.ok:
702704
tm_res = tm_res.json()
703705
if "areaOfInterest" in tm_res:

0 commit comments

Comments
 (0)