Spaces:
fantos
/
Runtime error

arxivgpt kim commited on
Commit
63e5794
โ€ข
1 Parent(s): 4421191

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -21,9 +21,22 @@ def search_pexels_images(query):
21
  headers = {"Authorization": API_KEY}
22
  response = requests.get(url, headers=headers)
23
  data = response.json()
24
- images_urls = [photo['src']['medium'] for photo in data['photos']]
 
 
 
 
 
 
 
 
 
 
 
 
25
  return images_urls
26
 
 
27
  def show_search_results(query):
28
  images_urls = search_pexels_images(query)
29
  return images_urls
 
21
  headers = {"Authorization": API_KEY}
22
  response = requests.get(url, headers=headers)
23
  data = response.json()
24
+
25
+ # ๊ณ ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€ URL๋งŒ ์„ ํƒํ•˜์—ฌ ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑ
26
+ images_urls = []
27
+ for photo in data.get('photos', []):
28
+ # 'large2x' ํ•ด์ƒ๋„์˜ ์ด๋ฏธ์ง€๊ฐ€ ์ œ๊ณต๋˜๋Š” ๊ฒฝ์šฐ, ํ•ด๋‹น URL ์‚ฌ์šฉ
29
+ if 'src' in photo and 'large2x' in photo['src']:
30
+ images_urls.append(photo['src']['large2x'])
31
+ # 'large2x' ํ•ด์ƒ๋„์˜ ์ด๋ฏธ์ง€๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ, 'large' ๋˜๋Š” 'original'์„ ๋Œ€์ฒด๋กœ ์‚ฌ์šฉ
32
+ elif 'large' in photo['src']:
33
+ images_urls.append(photo['src']['large'])
34
+ elif 'original' in photo['src']:
35
+ images_urls.append(photo['src']['original'])
36
+
37
  return images_urls
38
 
39
+
40
  def show_search_results(query):
41
  images_urls = search_pexels_images(query)
42
  return images_urls