seawolf2357 commited on
Commit
021f211
ยท
verified ยท
1 Parent(s): 359bc71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -10
app.py CHANGED
@@ -116,14 +116,14 @@ def format_results_from_raw(results):
116
 
117
  # ๋ฆฌ์ŠคํŠธ ํ˜•์‹์˜ ๊ธฐ์‚ฌ
118
  list_item = f"""
119
- {idx}. ์ œ๋ชฉ: {title}
120
- ๋งํฌ: {link}
121
- ์š”์•ฝ: {snippet}
122
- ์ถœ์ฒ˜: {channel}
123
- ์‹œ๊ฐ„: {time}
124
- ์ด๋ฏธ์ง€ URL: {image_url}
125
- ------------------------------
126
- """
127
  list_output += list_item
128
 
129
  # ๋‰ด์Šค ๊ฒฐ๊ณผ์™€ ๋””๋ฒ„๊ทธ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜
@@ -148,7 +148,7 @@ footer {
148
  """
149
 
150
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ
151
- with gr.Blocks(theme="Nymbo/Nymbo_Theme",css=css, title="24์‹œ๊ฐ„ ์ด๋‚ด ๋‰ด์Šค ๊ฒ€์ƒ‰ ์ธํ„ฐํŽ˜์ด์Šค") as iface:
152
  gr.Markdown("## 24์‹œ๊ฐ„ ์ด๋‚ด ๋‰ด์Šค ๊ฒ€์ƒ‰ ์ธํ„ฐํŽ˜์ด์Šค")
153
  gr.Markdown("๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ๊ตญ๊ฐ€๋ฅผ ์„ ํƒํ•˜์—ฌ 24์‹œ๊ฐ„ ์ด๋‚ด์˜ ๋‰ด์Šค ๊ฒฐ๊ณผ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.")
154
 
@@ -160,4 +160,25 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme",css=css, title="24์‹œ๊ฐ„ ์ด๋‚ด ๋‰ด์Šค
160
  page = gr.Slider(1, 10, 1, label="ํŽ˜์ด์ง€")
161
  num_result = gr.Slider(1, 100, 10, label="๊ฒฐ๊ณผ ์ˆ˜")
162
 
163
- search_button =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  # ๋ฆฌ์ŠคํŠธ ํ˜•์‹์˜ ๊ธฐ์‚ฌ
118
  list_item = f"""
119
+ {idx}. ์ œ๋ชฉ: {title}
120
+ ๋งํฌ: {link}
121
+ ์š”์•ฝ: {snippet}
122
+ ์ถœ์ฒ˜: {channel}
123
+ ์‹œ๊ฐ„: {time}
124
+ ์ด๋ฏธ์ง€ URL: {image_url}
125
+ ------------------------------
126
+ """
127
  list_output += list_item
128
 
129
  # ๋‰ด์Šค ๊ฒฐ๊ณผ์™€ ๋””๋ฒ„๊ทธ ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜
 
148
  """
149
 
150
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ
151
+ with gr.Blocks(css=css, title="24์‹œ๊ฐ„ ์ด๋‚ด ๋‰ด์Šค ๊ฒ€์ƒ‰ ์ธํ„ฐํŽ˜์ด์Šค") as iface:
152
  gr.Markdown("## 24์‹œ๊ฐ„ ์ด๋‚ด ๋‰ด์Šค ๊ฒ€์ƒ‰ ์ธํ„ฐํŽ˜์ด์Šค")
153
  gr.Markdown("๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ๊ตญ๊ฐ€๋ฅผ ์„ ํƒํ•˜์—ฌ 24์‹œ๊ฐ„ ์ด๋‚ด์˜ ๋‰ด์Šค ๊ฒฐ๊ณผ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.")
154
 
 
160
  page = gr.Slider(1, 10, 1, label="ํŽ˜์ด์ง€")
161
  num_result = gr.Slider(1, 100, 10, label="๊ฒฐ๊ณผ ์ˆ˜")
162
 
163
+ search_button = gr.Button("๊ฒ€์ƒ‰") # ๋ˆ„๋ฝ๋œ ๋ถ€๋ถ„ ์ถ”๊ฐ€
164
+
165
+ with gr.Tab("๋‰ด์Šค ๊ฒฐ๊ณผ"):
166
+ news_output = gr.HTML(label="๋‰ด์Šค ๊ฒฐ๊ณผ")
167
+
168
+ with gr.Tab("๋ฆฌ์ŠคํŠธ"):
169
+ list_output = gr.Textbox(label="๋ฆฌ์ŠคํŠธ ๊ฒฐ๊ณผ", lines=20)
170
+
171
+ with gr.Tab("๋””๋ฒ„๊ทธ ์ •๋ณด"):
172
+ debug_output = gr.Textbox(label="๋””๋ฒ„๊ทธ ์ •๋ณด", lines=10)
173
+
174
+ def search_and_display(query, country, page, num_result):
175
+ combined_output, list_output_text, debug_info = serphouse_search(query, country, page, num_result)
176
+ return {news_output: combined_output, list_output: list_output_text, debug_output: debug_info}
177
+
178
+ search_button.click(
179
+ search_and_display,
180
+ inputs=[query, country, page, num_result],
181
+ outputs=[news_output, list_output, debug_output]
182
+ )
183
+
184
+ iface.launch(auth=("gini", "pick"))