From b09acefa6a6e5790b2b544fb1855cbe7159cba4d Mon Sep 17 00:00:00 2001 From: smilerz Date: Thu, 6 Jan 2022 07:49:53 -0600 Subject: [PATCH] fix 1244 --- cookbook/views/api.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 8b3ff8fb9..b34d11318 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -1013,7 +1013,16 @@ def recipe_from_source(request): return JsonResponse({"recipe_json": get_from_scraper(scrape, request)}) elif (mode == 'source') or (mode == 'url' and auto == 'false'): if not data or data == 'undefined': - data = requests.get(url, headers=HEADERS).content + try: + data = requests.get(url, headers=HEADERS).content + except requests.exceptions.ConnectionError: + return JsonResponse( + { + 'error': True, + 'msg': _('Connection Refused.') + }, + status=400 + ) recipe_json, recipe_tree, recipe_html, images = get_recipe_from_source(data, url, request) if len(recipe_tree) == 0 and len(recipe_json) == 0: return JsonResponse(