Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,7 +66,7 @@ def fetch_search_results(query):
|
|
| 66 |
|
| 67 |
@app.route('/', methods=['GET'])
|
| 68 |
def search_page():
|
| 69 |
-
"""Generate and serve the search results page."""
|
| 70 |
query = request.args.get('query', '')
|
| 71 |
page = request.args.get('page', '1')
|
| 72 |
try:
|
|
@@ -77,15 +77,50 @@ def search_page():
|
|
| 77 |
if not query.strip():
|
| 78 |
html_content = """
|
| 79 |
<html>
|
| 80 |
-
<head
|
| 81 |
-
|
| 82 |
-
<
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</body>
|
| 90 |
</html>
|
| 91 |
"""
|
|
@@ -96,15 +131,52 @@ def search_page():
|
|
| 96 |
if error:
|
| 97 |
html_content = f"""
|
| 98 |
<html>
|
| 99 |
-
<head
|
| 100 |
-
|
| 101 |
-
<
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
</body>
|
| 109 |
</html>
|
| 110 |
"""
|
|
@@ -119,15 +191,51 @@ def search_page():
|
|
| 119 |
if start_idx >= len(results):
|
| 120 |
html_content = f"""
|
| 121 |
<html>
|
| 122 |
-
<head
|
| 123 |
-
|
| 124 |
-
<
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
</body>
|
| 132 |
</html>
|
| 133 |
"""
|
|
@@ -135,7 +243,7 @@ def search_page():
|
|
| 135 |
|
| 136 |
paginated_results = results[start_idx:end_idx]
|
| 137 |
|
| 138 |
-
# Generate full HTML page
|
| 139 |
html_content = f"""
|
| 140 |
<html>
|
| 141 |
<head>
|
|
@@ -144,32 +252,62 @@ def search_page():
|
|
| 144 |
body {{
|
| 145 |
font-family: Arial, sans-serif;
|
| 146 |
margin: 0;
|
| 147 |
-
padding:
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
}}
|
| 152 |
.search-box input[type="text"] {{
|
| 153 |
-
width:
|
| 154 |
-
padding:
|
| 155 |
font-size: 16px;
|
| 156 |
border: 1px solid #dfe1e5;
|
| 157 |
-
border-radius:
|
|
|
|
|
|
|
| 158 |
}}
|
| 159 |
.search-box input[type="submit"] {{
|
| 160 |
-
padding: 8px 16px;
|
| 161 |
-
font-size: 14px;
|
| 162 |
background-color: #f8f9fa;
|
| 163 |
-
border: 1px solid #
|
| 164 |
border-radius: 4px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
cursor: pointer;
|
| 166 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
.search-result {{
|
| 168 |
-
margin-bottom:
|
| 169 |
}}
|
| 170 |
.search-result a {{
|
| 171 |
color: #1a0dab;
|
| 172 |
-
font-size:
|
| 173 |
text-decoration: none;
|
| 174 |
}}
|
| 175 |
.search-result a:hover {{
|
|
@@ -178,20 +316,22 @@ def search_page():
|
|
| 178 |
.search-result .url {{
|
| 179 |
color: #006621;
|
| 180 |
font-size: 14px;
|
| 181 |
-
|
| 182 |
}}
|
| 183 |
.search-result p {{
|
| 184 |
-
color: #
|
| 185 |
font-size: 14px;
|
| 186 |
-
|
|
|
|
| 187 |
}}
|
| 188 |
.pagination {{
|
| 189 |
-
margin-top: 20px;
|
| 190 |
text-align: center;
|
|
|
|
| 191 |
}}
|
| 192 |
.pagination a, .pagination span {{
|
| 193 |
-
margin: 0 10px;
|
| 194 |
color: #1a0dab;
|
|
|
|
|
|
|
| 195 |
text-decoration: none;
|
| 196 |
}}
|
| 197 |
.pagination a:hover {{
|
|
@@ -200,14 +340,23 @@ def search_page():
|
|
| 200 |
</style>
|
| 201 |
</head>
|
| 202 |
<body>
|
| 203 |
-
<
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
<div class="results">
|
|
|
|
| 211 |
"""
|
| 212 |
|
| 213 |
for result in paginated_results:
|
|
|
|
| 66 |
|
| 67 |
@app.route('/', methods=['GET'])
|
| 68 |
def search_page():
|
| 69 |
+
"""Generate and serve the search results page styled like Google."""
|
| 70 |
query = request.args.get('query', '')
|
| 71 |
page = request.args.get('page', '1')
|
| 72 |
try:
|
|
|
|
| 77 |
if not query.strip():
|
| 78 |
html_content = """
|
| 79 |
<html>
|
| 80 |
+
<head>
|
| 81 |
+
<title>LLM Search Engine</title>
|
| 82 |
+
<style>
|
| 83 |
+
body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }
|
| 84 |
+
.header { text-align: center; margin-bottom: 20px; }
|
| 85 |
+
.logo { font-size: 36px; font-weight: bold; }
|
| 86 |
+
.logo span:nth-child(1) { color: #4285f4; } /* Blue */
|
| 87 |
+
.logo span:nth-child(2) { color: #ea4335; } /* Red */
|
| 88 |
+
.logo span:nth-child(3) { color: #fbbc05; } /* Yellow */
|
| 89 |
+
.logo span:nth-child(4) { color: #4285f4; } /* Blue */
|
| 90 |
+
.logo span:nth-child(5) { color: #34a853; } /* Green */
|
| 91 |
+
.search-box { max-width: 584px; margin: 0 auto; }
|
| 92 |
+
.search-box input[type="text"] {
|
| 93 |
+
width: 100%; padding: 12px 20px; font-size: 16px;
|
| 94 |
+
border: 1px solid #dfe1e5; border-radius: 24px;
|
| 95 |
+
box-shadow: 0 1px 6px rgba(32,33,36,0.28);
|
| 96 |
+
}
|
| 97 |
+
.search-box input[type="submit"] {
|
| 98 |
+
background-color: #f8f9fa; border: 1px solid #f8f9fa;
|
| 99 |
+
border-radius: 4px; color: #3c4043; font-size: 14px;
|
| 100 |
+
padding: 10px 16px; margin: 11px 4px; cursor: pointer;
|
| 101 |
+
}
|
| 102 |
+
.search-box input[type="submit"]:hover {
|
| 103 |
+
border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 104 |
+
}
|
| 105 |
+
.search-buttons { text-align: center; }
|
| 106 |
+
</style>
|
| 107 |
+
</head>
|
| 108 |
+
<body>
|
| 109 |
+
<div class="header">
|
| 110 |
+
<div class="logo">
|
| 111 |
+
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
<div class="search-box">
|
| 115 |
+
<form method="get" action="/">
|
| 116 |
+
<input type="text" name="query" placeholder="Search...">
|
| 117 |
+
<input type="hidden" name="page" value="1">
|
| 118 |
+
<div class="search-buttons">
|
| 119 |
+
<input type="submit" value="LLM Search">
|
| 120 |
+
<input type="submit" value="I'm Feeling Lucky" disabled>
|
| 121 |
+
</div>
|
| 122 |
+
</form>
|
| 123 |
+
</div>
|
| 124 |
</body>
|
| 125 |
</html>
|
| 126 |
"""
|
|
|
|
| 131 |
if error:
|
| 132 |
html_content = f"""
|
| 133 |
<html>
|
| 134 |
+
<head>
|
| 135 |
+
<title>LLM Search Engine</title>
|
| 136 |
+
<style>
|
| 137 |
+
body {{ font-family: Arial, sans-serif; margin: 0; padding: 20px; }}
|
| 138 |
+
.header {{ text-align: center; margin-bottom: 20px; }}
|
| 139 |
+
.logo {{ font-size: 36px; font-weight: bold; }}
|
| 140 |
+
.logo span:nth-child(1) {{ color: #4285f4; }}
|
| 141 |
+
.logo span:nth-child(2) {{ color: #ea4335; }}
|
| 142 |
+
.logo span:nth-child(3) {{ color: #fbbc05; }}
|
| 143 |
+
.logo span:nth-child(4) {{ color: #4285f4; }}
|
| 144 |
+
.logo span:nth-child(5) {{ color: #34a853; }}
|
| 145 |
+
.search-box {{ max-width: 584px; margin: 0 auto; }}
|
| 146 |
+
.search-box input[type="text"] {{
|
| 147 |
+
width: 100%; padding: 12px 20px; font-size: 16px;
|
| 148 |
+
border: 1px solid #dfe1e5; border-radius: 24px;
|
| 149 |
+
box-shadow: 0 1px 6px rgba(32,33,36,0.28);
|
| 150 |
+
}}
|
| 151 |
+
.search-box input[type="submit"] {{
|
| 152 |
+
background-color: #f8f9fa; border: 1px solid #f8f9fa;
|
| 153 |
+
border-radius: 4px; color: #3c4043; font-size: 14px;
|
| 154 |
+
padding: 10px 16px; margin: 11px 4px; cursor: pointer;
|
| 155 |
+
}}
|
| 156 |
+
.search-box input[type="submit"]:hover {{
|
| 157 |
+
border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 158 |
+
}}
|
| 159 |
+
.search-buttons {{ text-align: center; }}
|
| 160 |
+
.error {{ color: red; text-align: center; }}
|
| 161 |
+
</style>
|
| 162 |
+
</head>
|
| 163 |
+
<body>
|
| 164 |
+
<div class="header">
|
| 165 |
+
<div class="logo">
|
| 166 |
+
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 167 |
+
</div>
|
| 168 |
+
</div>
|
| 169 |
+
<div class="search-box">
|
| 170 |
+
<form method="get" action="/">
|
| 171 |
+
<input type="text" name="query" value="{html.escape(query)}">
|
| 172 |
+
<input type="hidden" name="page" value="1">
|
| 173 |
+
<div class="search-buttons">
|
| 174 |
+
<input type="submit" value="LLM Search">
|
| 175 |
+
<input type="submit" value="I'm Feeling Lucky" disabled>
|
| 176 |
+
</div>
|
| 177 |
+
</form>
|
| 178 |
+
</div>
|
| 179 |
+
<p class="error">{error}</p>
|
| 180 |
</body>
|
| 181 |
</html>
|
| 182 |
"""
|
|
|
|
| 191 |
if start_idx >= len(results):
|
| 192 |
html_content = f"""
|
| 193 |
<html>
|
| 194 |
+
<head>
|
| 195 |
+
<title>LLM Search Engine</title>
|
| 196 |
+
<style>
|
| 197 |
+
body {{ font-family: Arial, sans-serif; margin: 0; padding: 20px; }}
|
| 198 |
+
.header {{ text-align: center; margin-bottom: 20px; }}
|
| 199 |
+
.logo {{ font-size: 36px; font-weight: bold; }}
|
| 200 |
+
.logo span:nth-child(1) {{ color: #4285f4; }}
|
| 201 |
+
.logo span:nth-child(2) {{ color: #ea4335; }}
|
| 202 |
+
.logo span:nth-child(3) {{ color: #fbbc05; }}
|
| 203 |
+
.logo span:nth-child(4) {{ color: #4285f4; }}
|
| 204 |
+
.logo span:nth-child(5) {{ color: #34a853; }}
|
| 205 |
+
.search-box {{ max-width: 584px; margin: 0 auto; }}
|
| 206 |
+
.search-box input[type="text"] {{
|
| 207 |
+
width: 100%; padding: 12px 20px; font-size: 16px;
|
| 208 |
+
border: 1px solid #dfe1e5; border-radius: 24px;
|
| 209 |
+
box-shadow: 0 1px 6px rgba(32,33,36,0.28);
|
| 210 |
+
}}
|
| 211 |
+
.search-box input[type="submit"] {{
|
| 212 |
+
background-color: #f8f9fa; border: 1px solid #f8f9fa;
|
| 213 |
+
border-radius: 4px; color: #3c4043; font-size: 14px;
|
| 214 |
+
padding: 10px 16px; margin: 11px 4px; cursor: pointer;
|
| 215 |
+
}}
|
| 216 |
+
.search-box input[type="submit"]:hover {{
|
| 217 |
+
border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 218 |
+
}}
|
| 219 |
+
.search-buttons {{ text-align: center; }}
|
| 220 |
+
</style>
|
| 221 |
+
</head>
|
| 222 |
+
<body>
|
| 223 |
+
<div class="header">
|
| 224 |
+
<div class="logo">
|
| 225 |
+
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 226 |
+
</div>
|
| 227 |
+
</div>
|
| 228 |
+
<div class="search-box">
|
| 229 |
+
<form method="get" action="/">
|
| 230 |
+
<input type="text" name="query" value="{html.escape(query)}">
|
| 231 |
+
<input type="hidden" name="page" value="1">
|
| 232 |
+
<div class="search-buttons">
|
| 233 |
+
<input type="submit" value="LLM Search">
|
| 234 |
+
<input type="submit" value="I'm Feeling Lucky" disabled>
|
| 235 |
+
</div>
|
| 236 |
+
</form>
|
| 237 |
+
</div>
|
| 238 |
+
<p style="text-align: center;">No more results to display.</p>
|
| 239 |
</body>
|
| 240 |
</html>
|
| 241 |
"""
|
|
|
|
| 243 |
|
| 244 |
paginated_results = results[start_idx:end_idx]
|
| 245 |
|
| 246 |
+
# Generate full HTML page styled like Google
|
| 247 |
html_content = f"""
|
| 248 |
<html>
|
| 249 |
<head>
|
|
|
|
| 252 |
body {{
|
| 253 |
font-family: Arial, sans-serif;
|
| 254 |
margin: 0;
|
| 255 |
+
padding: 0;
|
| 256 |
+
color: #202124;
|
| 257 |
+
}}
|
| 258 |
+
.header {{
|
| 259 |
+
text-align: center;
|
| 260 |
+
padding: 20px 0;
|
| 261 |
+
}}
|
| 262 |
+
.logo {{
|
| 263 |
+
font-size: 36px;
|
| 264 |
+
font-weight: bold;
|
| 265 |
+
}}
|
| 266 |
+
.logo span:nth-child(1) {{ color: #4285f4; }}
|
| 267 |
+
.logo span:nth-child(2) {{ color: #ea4335; }}
|
| 268 |
+
.logo span:nth-child(3) {{ color: #fbbc05; }}
|
| 269 |
+
.logo span:nth-child(4) {{ color: #4285f4; }}
|
| 270 |
+
.logo span:nth-child(5) {{ color: #34a853; }}
|
| 271 |
+
.search-box {{
|
| 272 |
+
max-width: 584px;
|
| 273 |
+
margin: 0 auto 20px;
|
| 274 |
}}
|
| 275 |
.search-box input[type="text"] {{
|
| 276 |
+
width: 100%;
|
| 277 |
+
padding: 12px 20px;
|
| 278 |
font-size: 16px;
|
| 279 |
border: 1px solid #dfe1e5;
|
| 280 |
+
border-radius: 24px;
|
| 281 |
+
box-shadow: 0 1px 6px rgba(32,33,36,0.28);
|
| 282 |
+
outline: none;
|
| 283 |
}}
|
| 284 |
.search-box input[type="submit"] {{
|
|
|
|
|
|
|
| 285 |
background-color: #f8f9fa;
|
| 286 |
+
border: 1px solid #f8f9fa;
|
| 287 |
border-radius: 4px;
|
| 288 |
+
color: #3c4043;
|
| 289 |
+
font-size: 14px;
|
| 290 |
+
padding: 10px 16px;
|
| 291 |
+
margin: 11px 4px;
|
| 292 |
cursor: pointer;
|
| 293 |
}}
|
| 294 |
+
.search-box input[type="submit"]:hover {{
|
| 295 |
+
border: 1px solid #dadce0;
|
| 296 |
+
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 297 |
+
}}
|
| 298 |
+
.search-buttons {{
|
| 299 |
+
text-align: center;
|
| 300 |
+
}}
|
| 301 |
+
.results {{
|
| 302 |
+
max-width: 652px;
|
| 303 |
+
margin: 0 auto;
|
| 304 |
+
}}
|
| 305 |
.search-result {{
|
| 306 |
+
margin-bottom: 28px;
|
| 307 |
}}
|
| 308 |
.search-result a {{
|
| 309 |
color: #1a0dab;
|
| 310 |
+
font-size: 20px;
|
| 311 |
text-decoration: none;
|
| 312 |
}}
|
| 313 |
.search-result a:hover {{
|
|
|
|
| 316 |
.search-result .url {{
|
| 317 |
color: #006621;
|
| 318 |
font-size: 14px;
|
| 319 |
+
line-height: 20px;
|
| 320 |
}}
|
| 321 |
.search-result p {{
|
| 322 |
+
color: #4d5156;
|
| 323 |
font-size: 14px;
|
| 324 |
+
line-height: 22px;
|
| 325 |
+
margin: 0;
|
| 326 |
}}
|
| 327 |
.pagination {{
|
|
|
|
| 328 |
text-align: center;
|
| 329 |
+
margin: 40px 0;
|
| 330 |
}}
|
| 331 |
.pagination a, .pagination span {{
|
|
|
|
| 332 |
color: #1a0dab;
|
| 333 |
+
font-size: 14px;
|
| 334 |
+
margin: 0 8px;
|
| 335 |
text-decoration: none;
|
| 336 |
}}
|
| 337 |
.pagination a:hover {{
|
|
|
|
| 340 |
</style>
|
| 341 |
</head>
|
| 342 |
<body>
|
| 343 |
+
<div class="header">
|
| 344 |
+
<div class="logo">
|
| 345 |
+
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 346 |
+
</div>
|
| 347 |
+
</div>
|
| 348 |
+
<div class="search-box">
|
| 349 |
+
<form method="get" action="/">
|
| 350 |
+
<input type="text" name="query" value="{html.escape(query)}">
|
| 351 |
+
<input type="hidden" name="page" value="1">
|
| 352 |
+
<div class="search-buttons">
|
| 353 |
+
<input type="submit" value="LLM Search">
|
| 354 |
+
<input type="submit" value="I'm Feeling Lucky" disabled>
|
| 355 |
+
</div>
|
| 356 |
+
</form>
|
| 357 |
+
</div>
|
| 358 |
<div class="results">
|
| 359 |
+
<h2 style="font-size: 18px; color: #70757a; margin-bottom: 20px;">Results for '{html.escape(query)}' (Page {page} of {total_pages})</h2>
|
| 360 |
"""
|
| 361 |
|
| 362 |
for result in paginated_results:
|