seawolf2357 commited on
Commit
12567bd
·
verified ·
1 Parent(s): 8415ea5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -29
app.py CHANGED
@@ -66,20 +66,7 @@ def is_recent_news(time_str):
66
  return False
67
 
68
  def format_results(results):
69
- html_output = """
70
- <style>
71
- .news-container { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; }
72
- .news-item { background-color: #f9f9f9; border: 1px solid #ddd; padding: 20px; margin-bottom: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
73
- .news-title { font-size: 20px; color: #1a0dab; text-decoration: none; font-weight: bold; }
74
- .news-title:hover { text-decoration: underline; }
75
- .news-snippet { color: #545454; margin: 15px 0; line-height: 1.4; }
76
- .news-meta { font-size: 14px; color: #006621; }
77
- .no-results { text-align: center; color: #666; font-style: italic; }
78
- .debug-info { background-color: #f0f0f0; padding: 10px; margin-top: 20px; border-radius: 5px; white-space: pre-wrap; }
79
- </style>
80
- <div class="news-container">
81
- <h2 style="text-align: center; color: #333;">Recent News Results</h2>
82
- """
83
 
84
  try:
85
  if isinstance(results, dict) and "results" in results and "news" in results["results"]:
@@ -102,9 +89,6 @@ def format_results(results):
102
  except Exception as e:
103
  html_output += f'<p class="no-results">Error processing results: {str(e)}</p>'
104
 
105
- # 디버그 정보 추가
106
- html_output += f'<div class="debug-info"><h3>Debug Info:</h3><pre>{json.dumps(results, indent=2)}</pre></div>'
107
-
108
  html_output += "</div>"
109
  return html_output
110
 
@@ -112,24 +96,17 @@ def serphouse_search(query, country, page, num_result):
112
  results = search_serphouse(query, country, page, num_result)
113
  return format_results(results)
114
 
115
- css = """
116
- footer {
117
- visibility: hidden;
118
- }
119
- """
120
-
121
  iface = gr.Interface(
122
  fn=serphouse_search,
123
  inputs=[
124
  gr.Textbox(label="Search Query"),
125
- gr.Dropdown(MAJOR_COUNTRIES, label="Country"),
126
- gr.Slider(1, 10, 1, label="Page"),
127
- gr.Slider(1, 100, 10, label="Number of Results")
128
  ],
129
  outputs="html",
130
  title="Global News Search AI",
131
- theme="Nymbo/Nymbo_Theme",
132
- css=css
133
  )
134
 
135
- iface.launch()
 
66
  return False
67
 
68
  def format_results(results):
69
+ html_output = "<div class='news-container'>"
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  try:
72
  if isinstance(results, dict) and "results" in results and "news" in results["results"]:
 
89
  except Exception as e:
90
  html_output += f'<p class="no-results">Error processing results: {str(e)}</p>'
91
 
 
 
 
92
  html_output += "</div>"
93
  return html_output
94
 
 
96
  results = search_serphouse(query, country, page, num_result)
97
  return format_results(results)
98
 
 
 
 
 
 
 
99
  iface = gr.Interface(
100
  fn=serphouse_search,
101
  inputs=[
102
  gr.Textbox(label="Search Query"),
103
+ gr.Dropdown(choices=MAJOR_COUNTRIES, label="Country"),
104
+ gr.Slider(minimum=1, maximum=10, step=1, label="Page"),
105
+ gr.Slider(minimum=1, maximum=100, step=10, label="Number of Results")
106
  ],
107
  outputs="html",
108
  title="Global News Search AI",
109
+ theme="huggingface"
 
110
  )
111
 
112
+ iface.launch()