pvanand commited on
Commit
6625f9a
1 Parent(s): 3909bb8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -1
main.py CHANGED
@@ -388,13 +388,15 @@ def get_pexels_image(query):
388
  if data["total_results"] > 0:
389
  return data["photos"][0]["src"]["medium"]
390
  return default_img_url
391
- except:
 
392
  return default_img_url
393
 
394
  def replace_image_keywords(text):
395
  def replace_match(match):
396
  bg_params = match.group(1)
397
  keyword = re.sub(r'[^\w\s]', ' ', match.group(2)).strip()
 
398
  image_url = get_pexels_image(keyword)
399
  return f"![bg {bg_params}]({image_url})"
400
 
 
388
  if data["total_results"] > 0:
389
  return data["photos"][0]["src"]["medium"]
390
  return default_img_url
391
+ except Exception as e:
392
+ logger.error(f"An error occurred for Pexels API: {e}")
393
  return default_img_url
394
 
395
  def replace_image_keywords(text):
396
  def replace_match(match):
397
  bg_params = match.group(1)
398
  keyword = re.sub(r'[^\w\s]', ' ', match.group(2)).strip()
399
+ logger.info(f"Extracted keywords for pexels : {keyword}")
400
  image_url = get_pexels_image(keyword)
401
  return f"![bg {bg_params}]({image_url})"
402