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 |
-
"""Serve the initial page or process search with progress bar."""
|
| 70 |
query = request.args.get('query', '')
|
| 71 |
page = request.args.get('page', '1')
|
| 72 |
btn = request.args.get('btn', 'LLM Search')
|
|
@@ -107,19 +107,21 @@ def search_page():
|
|
| 107 |
.search-buttons { text-align: center; }
|
| 108 |
.progress-container { display: none; max-width: 584px; margin: 20px auto; }
|
| 109 |
.progress-bar {
|
| 110 |
-
width:
|
| 111 |
-
border-radius: 10px; animation:
|
| 112 |
}
|
| 113 |
-
@keyframes
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
100% { width: 0%; }
|
| 117 |
}
|
| 118 |
</style>
|
| 119 |
<script>
|
| 120 |
function showProgress() {
|
| 121 |
document.getElementById('progress').style.display = 'block';
|
| 122 |
}
|
|
|
|
|
|
|
|
|
|
| 123 |
</script>
|
| 124 |
</head>
|
| 125 |
<body>
|
|
@@ -146,7 +148,7 @@ def search_page():
|
|
| 146 |
"""
|
| 147 |
return render_template_string(html_content)
|
| 148 |
|
| 149 |
-
#
|
| 150 |
results, error = fetch_search_results(query)
|
| 151 |
|
| 152 |
if error:
|
|
@@ -181,14 +183,14 @@ def search_page():
|
|
| 181 |
.error {{ color: red; text-align: center; }}
|
| 182 |
</style>
|
| 183 |
</head>
|
| 184 |
-
<body>
|
| 185 |
<div class="header">
|
| 186 |
<div class="logo">
|
| 187 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 188 |
</div>
|
| 189 |
</div>
|
| 190 |
<div class="search-box">
|
| 191 |
-
<form method="get" action="/">
|
| 192 |
<input type="text" name="query" value="{html.escape(query)}">
|
| 193 |
<input type="hidden" name="page" value="1">
|
| 194 |
<div class="search-buttons">
|
|
@@ -210,9 +212,23 @@ def search_page():
|
|
| 210 |
<html>
|
| 211 |
<head>
|
| 212 |
<meta http-equiv="refresh" content="0; url={first_url}">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
</head>
|
| 214 |
<body>
|
|
|
|
|
|
|
|
|
|
| 215 |
<p>Redirecting to {first_url}...</p>
|
|
|
|
|
|
|
|
|
|
| 216 |
</body>
|
| 217 |
</html>
|
| 218 |
""", mimetype="text/html")
|
|
@@ -253,14 +269,14 @@ def search_page():
|
|
| 253 |
.search-buttons {{ text-align: center; }}
|
| 254 |
</style>
|
| 255 |
</head>
|
| 256 |
-
<body>
|
| 257 |
<div class="header">
|
| 258 |
<div class="logo">
|
| 259 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 260 |
</div>
|
| 261 |
</div>
|
| 262 |
<div class="search-box">
|
| 263 |
-
<form method="get" action="/">
|
| 264 |
<input type="text" name="query" value="{html.escape(query)}">
|
| 265 |
<input type="hidden" name="page" value="1">
|
| 266 |
<div class="search-buttons">
|
|
@@ -318,22 +334,24 @@ def search_page():
|
|
| 318 |
.pagination a:hover {{ text-decoration: underline; }}
|
| 319 |
.progress-container {{ display: none; max-width: 584px; margin: 20px auto; }}
|
| 320 |
.progress-bar {{
|
| 321 |
-
width:
|
| 322 |
-
border-radius: 10px; animation:
|
| 323 |
}}
|
| 324 |
-
@keyframes
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
100% {{ width: 0%; }}
|
| 328 |
}}
|
| 329 |
</style>
|
| 330 |
<script>
|
| 331 |
function showProgress() {{
|
| 332 |
document.getElementById('progress').style.display = 'block';
|
| 333 |
}}
|
|
|
|
|
|
|
|
|
|
| 334 |
</script>
|
| 335 |
</head>
|
| 336 |
-
<body>
|
| 337 |
<div class="header">
|
| 338 |
<div class="logo">
|
| 339 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
|
@@ -369,8 +387,8 @@ def search_page():
|
|
| 369 |
"""
|
| 370 |
|
| 371 |
encoded_query = quote(query)
|
| 372 |
-
prev_link = f'<a href="/?query={encoded_query}&page={page-1}&btn=LLM+Search">Previous</a>' if page > 1 else '<span>Previous</span>'
|
| 373 |
-
next_link = f'<a href="/?query={encoded_query}&page={page+1}&btn=LLM+Search">Next</a>' if page < total_pages else '<span>Next</span>'
|
| 374 |
html_content += f"""
|
| 375 |
</div>
|
| 376 |
<div class="pagination">
|
|
|
|
| 66 |
|
| 67 |
@app.route('/', methods=['GET'])
|
| 68 |
def search_page():
|
| 69 |
+
"""Serve the initial page or process search with a decaying progress bar."""
|
| 70 |
query = request.args.get('query', '')
|
| 71 |
page = request.args.get('page', '1')
|
| 72 |
btn = request.args.get('btn', 'LLM Search')
|
|
|
|
| 107 |
.search-buttons { text-align: center; }
|
| 108 |
.progress-container { display: none; max-width: 584px; margin: 20px auto; }
|
| 109 |
.progress-bar {
|
| 110 |
+
width: 100%; height: 20px; background-color: #4285f4;
|
| 111 |
+
border-radius: 10px; animation: decay 10s linear forwards;
|
| 112 |
}
|
| 113 |
+
@keyframes decay {
|
| 114 |
+
from { width: 100%; }
|
| 115 |
+
to { width: 0%; }
|
|
|
|
| 116 |
}
|
| 117 |
</style>
|
| 118 |
<script>
|
| 119 |
function showProgress() {
|
| 120 |
document.getElementById('progress').style.display = 'block';
|
| 121 |
}
|
| 122 |
+
function hideProgress() {
|
| 123 |
+
document.getElementById('progress').style.display = 'none';
|
| 124 |
+
}
|
| 125 |
</script>
|
| 126 |
</head>
|
| 127 |
<body>
|
|
|
|
| 148 |
"""
|
| 149 |
return render_template_string(html_content)
|
| 150 |
|
| 151 |
+
# Fetch results after showing progress bar
|
| 152 |
results, error = fetch_search_results(query)
|
| 153 |
|
| 154 |
if error:
|
|
|
|
| 183 |
.error {{ color: red; text-align: center; }}
|
| 184 |
</style>
|
| 185 |
</head>
|
| 186 |
+
<body onload="hideProgress()">
|
| 187 |
<div class="header">
|
| 188 |
<div class="logo">
|
| 189 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 190 |
</div>
|
| 191 |
</div>
|
| 192 |
<div class="search-box">
|
| 193 |
+
<form method="get" action="/" onsubmit="showProgress()">
|
| 194 |
<input type="text" name="query" value="{html.escape(query)}">
|
| 195 |
<input type="hidden" name="page" value="1">
|
| 196 |
<div class="search-buttons">
|
|
|
|
| 212 |
<html>
|
| 213 |
<head>
|
| 214 |
<meta http-equiv="refresh" content="0; url={first_url}">
|
| 215 |
+
<style>
|
| 216 |
+
.progress-container {{ max-width: 584px; margin: 20px auto; }}
|
| 217 |
+
.progress-bar {{
|
| 218 |
+
width: 100%; height: 20px; background-color: #4285f4;
|
| 219 |
+
border-radius: 10px; animation: decay 10s linear forwards;
|
| 220 |
+
}}
|
| 221 |
+
@keyframes decay {{ from {{ width: 100%; }} to {{ width: 0%; }} }}
|
| 222 |
+
</style>
|
| 223 |
</head>
|
| 224 |
<body>
|
| 225 |
+
<div class="progress-container" id="progress">
|
| 226 |
+
<div class="progress-bar"></div>
|
| 227 |
+
</div>
|
| 228 |
<p>Redirecting to {first_url}...</p>
|
| 229 |
+
<script>
|
| 230 |
+
setTimeout(function() {{ window.location.href = "{first_url}"; }}, 100);
|
| 231 |
+
</script>
|
| 232 |
</body>
|
| 233 |
</html>
|
| 234 |
""", mimetype="text/html")
|
|
|
|
| 269 |
.search-buttons {{ text-align: center; }}
|
| 270 |
</style>
|
| 271 |
</head>
|
| 272 |
+
<body onload="hideProgress()">
|
| 273 |
<div class="header">
|
| 274 |
<div class="logo">
|
| 275 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
| 276 |
</div>
|
| 277 |
</div>
|
| 278 |
<div class="search-box">
|
| 279 |
+
<form method="get" action="/" onsubmit="showProgress()">
|
| 280 |
<input type="text" name="query" value="{html.escape(query)}">
|
| 281 |
<input type="hidden" name="page" value="1">
|
| 282 |
<div class="search-buttons">
|
|
|
|
| 334 |
.pagination a:hover {{ text-decoration: underline; }}
|
| 335 |
.progress-container {{ display: none; max-width: 584px; margin: 20px auto; }}
|
| 336 |
.progress-bar {{
|
| 337 |
+
width: 100%; height: 20px; background-color: #4285f4;
|
| 338 |
+
border-radius: 10px; animation: decay 10s linear forwards;
|
| 339 |
}}
|
| 340 |
+
@keyframes decay {{
|
| 341 |
+
from {{ width: 100%; }}
|
| 342 |
+
to {{ width: 0%; }}
|
|
|
|
| 343 |
}}
|
| 344 |
</style>
|
| 345 |
<script>
|
| 346 |
function showProgress() {{
|
| 347 |
document.getElementById('progress').style.display = 'block';
|
| 348 |
}}
|
| 349 |
+
function hideProgress() {{
|
| 350 |
+
document.getElementById('progress').style.display = 'none';
|
| 351 |
+
}}
|
| 352 |
</script>
|
| 353 |
</head>
|
| 354 |
+
<body onload="hideProgress()">
|
| 355 |
<div class="header">
|
| 356 |
<div class="logo">
|
| 357 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
|
|
|
| 387 |
"""
|
| 388 |
|
| 389 |
encoded_query = quote(query)
|
| 390 |
+
prev_link = f'<a href="/?query={encoded_query}&page={page-1}&btn=LLM+Search" onclick="showProgress()">Previous</a>' if page > 1 else '<span>Previous</span>'
|
| 391 |
+
next_link = f'<a href="/?query={encoded_query}&page={page+1}&btn=LLM+Search" onclick="showProgress()">Next</a>' if page < total_pages else '<span>Next</span>'
|
| 392 |
html_content += f"""
|
| 393 |
</div>
|
| 394 |
<div class="pagination">
|