mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-22 01:51:08 -05:00
Add timeout to requests calls
This commit is contained in:
@@ -189,7 +189,7 @@ class Command(BaseCommand):
|
||||
|
||||
def download_image(self, url):
|
||||
"""Download image from URL and return as Django File object"""
|
||||
response = requests.get(url)
|
||||
response = requests.get(url, timeout=60)
|
||||
if response.status_code == 200:
|
||||
img_temp = NamedTemporaryFile(delete=True)
|
||||
img_temp.write(response.content)
|
||||
|
||||
@@ -79,7 +79,7 @@ def location_search(request: HttpRequest) -> JsonResponse:
|
||||
"limit": 10,
|
||||
},
|
||||
headers={"User-Agent": "ThrillWiki/1.0"},
|
||||
)
|
||||
timeout=60)
|
||||
|
||||
if response.status_code == 200:
|
||||
results = response.json()
|
||||
@@ -128,7 +128,7 @@ def reverse_geocode(request: HttpRequest) -> JsonResponse:
|
||||
"accept-language": "en",
|
||||
},
|
||||
headers={"User-Agent": "ThrillWiki/1.0"},
|
||||
)
|
||||
timeout=60)
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
|
||||
Reference in New Issue
Block a user