arxivgpt kim
commited on
Commit
โข
63e5794
1
Parent(s):
4421191
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|