Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
from serpapi import GoogleSearch
|
3 |
|
4 |
def dmz_history():
|
5 |
# DMZ์ ์ญ์ฌ์ ๋ํ ์ ๋ณด๋ฅผ ๋ฐํํฉ๋๋ค.
|
@@ -9,35 +8,12 @@ def dmz_restaurants():
|
|
9 |
# DMZ ์ฃผ๋ณ์ ๋ง์ง ์ ๋ณด๋ฅผ ๋ฐํํฉ๋๋ค.
|
10 |
return "DMZ ์ฃผ๋ณ์๋ 'ํํ์ ๋๋ฆฌ' ๋ฑ ๋ง์ง์ด ์์ต๋๋ค."
|
11 |
|
12 |
-
def search_images(query):
|
13 |
-
params = {
|
14 |
-
"engine": "google",
|
15 |
-
"q": query,
|
16 |
-
"tbm": "isch", # ์ด๋ฏธ์ง ๊ฒ์์ ์ํ ํ๋ผ๋ฏธํฐ
|
17 |
-
"api_key": "56b76bc0db7f66e70958810f3486e99a7ad4fc9b4ad0719e34478b20d2f7ec4f"
|
18 |
-
}
|
19 |
-
|
20 |
-
search = GoogleSearch(params)
|
21 |
-
results = search.get_dict()
|
22 |
-
images_results = results.get("images_results", [])
|
23 |
-
|
24 |
-
# ์ด๋ฏธ์ง URL๋ง ์ถ์ถ
|
25 |
-
images_urls = [image["thumbnail"] for image in images_results]
|
26 |
-
|
27 |
-
return images_urls
|
28 |
-
|
29 |
with gr.Blocks() as demo:
|
30 |
gr.Markdown("### DMZ ์ฌํ ํ๋ก๊ทธ๋จ")
|
31 |
with gr.Tab("์ญ์ฌ"):
|
32 |
gr.Markdown(dmz_history())
|
33 |
with gr.Tab("๋ง์ง"):
|
34 |
gr.Markdown(dmz_restaurants())
|
35 |
-
with gr.Tab("์ด๋ฏธ์ง ๊ฒ์"):
|
36 |
-
with gr.Row():
|
37 |
-
query_input = gr.Textbox(lines=2, placeholder="DMZ์ ๋ํด ๊ฒ์ํ ํค์๋๋ฅผ ์
๋ ฅํ์ธ์...")
|
38 |
-
search_button = gr.Button("๊ฒ์")
|
39 |
-
gallery = gr.Gallery()
|
40 |
-
search_button.click(search_images, inputs=query_input, outputs=gallery)
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
def dmz_history():
|
4 |
# DMZ์ ์ญ์ฌ์ ๋ํ ์ ๋ณด๋ฅผ ๋ฐํํฉ๋๋ค.
|
|
|
8 |
# DMZ ์ฃผ๋ณ์ ๋ง์ง ์ ๋ณด๋ฅผ ๋ฐํํฉ๋๋ค.
|
9 |
return "DMZ ์ฃผ๋ณ์๋ 'ํํ์ ๋๋ฆฌ' ๋ฑ ๋ง์ง์ด ์์ต๋๋ค."
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
with gr.Blocks() as demo:
|
12 |
gr.Markdown("### DMZ ์ฌํ ํ๋ก๊ทธ๋จ")
|
13 |
with gr.Tab("์ญ์ฌ"):
|
14 |
gr.Markdown(dmz_history())
|
15 |
with gr.Tab("๋ง์ง"):
|
16 |
gr.Markdown(dmz_restaurants())
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
if __name__ == "__main__":
|
19 |
demo.launch()
|