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 a left-to-right progress bar."""
|
| 70 |
query = request.args.get('query', '')
|
| 71 |
page = request.args.get('page', '1')
|
| 72 |
btn = request.args.get('btn', 'LLM Search')
|
|
@@ -105,7 +105,7 @@ def search_page():
|
|
| 105 |
border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 106 |
}
|
| 107 |
.search-buttons { text-align: center; }
|
| 108 |
-
.progress-container { display: none; max-width: 584px; margin: 20px auto; }
|
| 109 |
.progress-bar {
|
| 110 |
width: 0%; height: 20px; background-color: #4285f4;
|
| 111 |
border-radius: 10px; animation: progress 30s ease-out forwards;
|
|
@@ -218,7 +218,7 @@ def search_page():
|
|
| 218 |
<head>
|
| 219 |
<meta http-equiv="refresh" content="0; url={first_url}">
|
| 220 |
<style>
|
| 221 |
-
.progress-container {{ max-width: 584px; margin: 20px auto; }}
|
| 222 |
.progress-bar {{
|
| 223 |
width: 0%; height: 20px; background-color: #4285f4;
|
| 224 |
border-radius: 10px; animation: progress 30s ease-out forwards;
|
|
@@ -351,6 +351,7 @@ def search_page():
|
|
| 351 |
from {{ width: 0%; }}
|
| 352 |
to {{ width: 100%; }}
|
| 353 |
}}
|
|
|
|
| 354 |
</style>
|
| 355 |
<script>
|
| 356 |
function showProgress() {{
|
|
@@ -359,9 +360,29 @@ def search_page():
|
|
| 359 |
function hideProgress() {{
|
| 360 |
document.getElementById('progress').style.display = 'none';
|
| 361 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
</script>
|
| 363 |
</head>
|
| 364 |
-
<body
|
| 365 |
<div class="header">
|
| 366 |
<div class="logo">
|
| 367 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|
|
|
|
| 66 |
|
| 67 |
@app.route('/', methods=['GET'])
|
| 68 |
def search_page():
|
| 69 |
+
"""Serve the initial page or process search with a left-to-right progress bar and URL validation."""
|
| 70 |
query = request.args.get('query', '')
|
| 71 |
page = request.args.get('page', '1')
|
| 72 |
btn = request.args.get('btn', 'LLM Search')
|
|
|
|
| 105 |
border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 106 |
}
|
| 107 |
.search-buttons { text-align: center; }
|
| 108 |
+
.progress-container { display: none; max-width: 584px; margin: 20px auto; border: 1px solid #dfe1e5; border-radius: 10px; }
|
| 109 |
.progress-bar {
|
| 110 |
width: 0%; height: 20px; background-color: #4285f4;
|
| 111 |
border-radius: 10px; animation: progress 30s ease-out forwards;
|
|
|
|
| 218 |
<head>
|
| 219 |
<meta http-equiv="refresh" content="0; url={first_url}">
|
| 220 |
<style>
|
| 221 |
+
.progress-container {{ max-width: 584px; margin: 20px auto; border: 1px solid #dfe1e5; border-radius: 10px; }}
|
| 222 |
.progress-bar {{
|
| 223 |
width: 0%; height: 20px; background-color: #4285f4;
|
| 224 |
border-radius: 10px; animation: progress 30s ease-out forwards;
|
|
|
|
| 351 |
from {{ width: 0%; }}
|
| 352 |
to {{ width: 100%; }}
|
| 353 |
}}
|
| 354 |
+
.broken {{ color: #d93025; }}
|
| 355 |
</style>
|
| 356 |
<script>
|
| 357 |
function showProgress() {{
|
|
|
|
| 360 |
function hideProgress() {{
|
| 361 |
document.getElementById('progress').style.display = 'none';
|
| 362 |
}}
|
| 363 |
+
async function checkLinks() {{
|
| 364 |
+
const links = document.querySelectorAll('.search-result a');
|
| 365 |
+
for (let i = 0; i < links.length; i++) {{
|
| 366 |
+
const url = links[i].href;
|
| 367 |
+
try {{
|
| 368 |
+
const response = await fetch(url, {{ method: 'HEAD', mode: 'no-cors' }});
|
| 369 |
+
if (!response.ok && response.status !== 0) {{ // 0 indicates no-cors limitation
|
| 370 |
+
links[i].textContent += ' [Broken Link]';
|
| 371 |
+
links[i].classList.add('broken');
|
| 372 |
+
}}
|
| 373 |
+
}} catch (error) {{
|
| 374 |
+
links[i].textContent += ' [Broken Link]';
|
| 375 |
+
links[i].classList.add('broken');
|
| 376 |
+
}}
|
| 377 |
+
}}
|
| 378 |
+
}}
|
| 379 |
+
window.onload = function() {{
|
| 380 |
+
hideProgress();
|
| 381 |
+
checkLinks();
|
| 382 |
+
}};
|
| 383 |
</script>
|
| 384 |
</head>
|
| 385 |
+
<body>
|
| 386 |
<div class="header">
|
| 387 |
<div class="logo">
|
| 388 |
<span>L</span><span>L</span><span>M</span><span> </span><span>Search</span>
|