Update app.py
Browse files
app.py
CHANGED
|
@@ -21,8 +21,12 @@ def search_videos(keyword):
|
|
| 21 |
url = "https://api.pexels.com/videos/search"
|
| 22 |
response = requests.get(url, headers=headers, params=params)
|
| 23 |
data = response.json()
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
| 28 |
with gr.Blocks() as app:
|
|
@@ -30,15 +34,15 @@ with gr.Blocks() as app:
|
|
| 30 |
with gr.Row():
|
| 31 |
image_search_input = gr.Textbox(label="Search for Images")
|
| 32 |
image_search_button = gr.Button("Search")
|
| 33 |
-
image_gallery = gr.Gallery()
|
| 34 |
image_search_button.click(search_images, inputs=image_search_input, outputs=image_gallery)
|
| 35 |
|
| 36 |
with gr.Tab("Videos"):
|
| 37 |
with gr.Row():
|
| 38 |
video_search_input = gr.Textbox(label="Search for Videos")
|
| 39 |
video_search_button = gr.Button("Search")
|
| 40 |
-
|
| 41 |
-
video_search_button.click(search_videos, inputs=video_search_input, outputs=
|
| 42 |
|
| 43 |
# ์ธํฐํ์ด์ค ์คํ
|
| 44 |
app.launch()
|
|
|
|
| 21 |
url = "https://api.pexels.com/videos/search"
|
| 22 |
response = requests.get(url, headers=headers, params=params)
|
| 23 |
data = response.json()
|
| 24 |
+
# ์ฌ๋ฌ ๋น๋์ค URL ์ค ์ฒซ ๋ฒ์งธ๋ง ๋ฐํ
|
| 25 |
+
if data['videos']:
|
| 26 |
+
first_video_url = data['videos'][0]['video_files'][0]['link']
|
| 27 |
+
return first_video_url
|
| 28 |
+
else:
|
| 29 |
+
return "No videos found"
|
| 30 |
|
| 31 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
| 32 |
with gr.Blocks() as app:
|
|
|
|
| 34 |
with gr.Row():
|
| 35 |
image_search_input = gr.Textbox(label="Search for Images")
|
| 36 |
image_search_button = gr.Button("Search")
|
| 37 |
+
image_gallery = gr.Gallery() # style ๋ฉ์๋ ํธ์ถ ์ ๊ฑฐ
|
| 38 |
image_search_button.click(search_images, inputs=image_search_input, outputs=image_gallery)
|
| 39 |
|
| 40 |
with gr.Tab("Videos"):
|
| 41 |
with gr.Row():
|
| 42 |
video_search_input = gr.Textbox(label="Search for Videos")
|
| 43 |
video_search_button = gr.Button("Search")
|
| 44 |
+
video_output = gr.Video() # ๋น๋์ค ๊ฐค๋ฌ๋ฆฌ ๋์ ๋จ์ผ ๋น๋์ค ์ถ๋ ฅ์ผ๋ก ๋ณ๊ฒฝ
|
| 45 |
+
video_search_button.click(search_videos, inputs=video_search_input, outputs=video_output)
|
| 46 |
|
| 47 |
# ์ธํฐํ์ด์ค ์คํ
|
| 48 |
app.launch()
|