corrected api import workflow

This commit is contained in:
smilerz 2021-04-16 14:09:10 -05:00
parent b2c1c6e301
commit 724748d38a

View File

@ -584,7 +584,7 @@ def recipe_from_source(request):
status=400) status=400)
else: else:
return JsonResponse({"recipe_json": get_from_scraper(scrape, request.space)}) return JsonResponse({"recipe_json": get_from_scraper(scrape, request.space)})
else: elif mode == 'url' and auto == 'false':
try: try:
response = requests.get(url, headers=HEADERS) response = requests.get(url, headers=HEADERS)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
@ -605,7 +605,7 @@ def recipe_from_source(request):
status=400 status=400
) )
data = response.text data = response.text
if (mode == 'source') or (mode == 'url' and auto == 'false'): elif (mode == 'source') or (mode == 'url' and auto == 'false'):
if not data or data == 'undefined': if not data or data == 'undefined':
data = requests.get(url, headers=HEADERS).content data = requests.get(url, headers=HEADERS).content
recipe_json, recipe_tree, recipe_html, images = get_recipe_from_source(data, url, request.space) recipe_json, recipe_tree, recipe_html, images = get_recipe_from_source(data, url, request.space)
@ -625,6 +625,7 @@ def recipe_from_source(request):
'images': images, 'images': images,
}) })
else:
return JsonResponse( return JsonResponse(
{ {
'error': True, 'error': True,