Spaces:
Paused
Paused
Update app.py
Browse files65 unmodified lines666768697071724 unmodified lines7778798081828384858687888990914 unmodified lines969798991001011021031041051061071081091108 unmodified lines1191201211221231241251261271281291301311321331 unmodified line1351361371381391401412 unmodified lines1441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741752 unmodified lines1781791801811821831841851861871881891901911921931941951961972 unmodified lines20020120220320420520620720820921021121221365 unmodified lines@app.route('/', methods=['GET'])def search_page():"""Generate and serve the search results page."""query = request.args.get('query', '')page = request.args.get('page', '1')try:4 unmodified linesif not query.strip():html_content = """<html><head><title>LLM Search Engine</title></head><body style="font-family: Arial, sans-serif;"><h1>LLM Search Engine</h1><form method="get" action="/"><input type="text" name="query" placeholder="Type your search here..."><input type="submit" value="Search"><input type="hidden" name="page" value="1"></form><p>Please enter a search query.</p></body></html>"""4 unmodified linesif error:html_content = f"""<html><head><title>LLM Search Engine</title></head><body style="font-family: Arial, sans-serif;"><h1>LLM Search Engine</h1><form method="get" action="/"><input type="text" name="query" value="{html.escape(query)}"><input type="submit" value="Search"><input type="hidden" name="page" value="1"></form><p style="color: red;">{error}</p></body></html>"""8 unmodified linesif start_idx >= len(results):html_content = f"""<html><head><title>LLM Search Engine</title></head><body style="font-family: Arial, sans-serif;"><h1>LLM Search Engine</h1><form method="get" action="/"><input type="text" name="query" value="{html.escape(query)}"><input type="submit" value="Search"><input type="hidden" name="page" value="1"></form><p>No more results to display.</p></body></html>"""1 unmodified linepaginated_results = results[start_idx:end_idx]# Generate full HTML pagehtml_content = f"""<html><head>2 unmodified linesbody {{font-family: Arial, sans-serif;margin: 0;padding: 20px;max-width: 800px;margin-left: auto;margin-right: auto;}}.search-box input[type="text"] {{width: 70%;padding: 8px;font-size: 16px;border: 1px solid #dfe1e5;border-radius: 4px;}}.search-box input[type="submit"] {{padding: 8px 16px;font-size: 14px;background-color: #f8f9fa;border: 1px solid #dfe1e5;border-radius: 4px;cursor: pointer;}}.search-result {{margin-bottom: 20px;}}.search-result a {{color: #1a0dab;font-size: 18px;text-decoration: none;}}.search-result a:hover {{2 unmodified lines.search-result .url {{color: #006621;font-size: 14px;margin: 2px 0;}}.search-result p {{color: #545454;font-size: 14px;margin: 2px 0;}}.pagination {{margin-top: 20px;text-align: center;}}.pagination a, .pagination span {{margin: 0 10px;color: #1a0dab;text-decoration: none;}}.pagination a:hover {{2 unmodified lines</style></head><body><h1>LLM Search Engine</h1><form class="search-box" method="get" action="/"><input type="text" name="query" value="{html.escape(query)}"><input type="submit" value="Search"><input type="hidden" name="page" value="1"></form><h2>Results for '{html.escape(query)}' (Page {page} of {total_pages})</h2><div class="results">"""for result in paginated_results:65 unmodified lines666768697071724 unmodified lines77787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251264 unmodified lines1311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811828 unmodified lines1911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402411 unmodified line2432442452462472482492 unmodified lines2522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123132 unmodified lines3163173183193203213223233243253263273283293303313323333343353363372 unmodified lines34034134234334434534634734834935035135235335435535635735835936036136265 unmodified lines@app.route('/', methods=['GET'])def search_page():"""Generate and serve the search results page styled like Google."""query = request.args.get('query', '')page = request.args.get('page', '1')try:4 unmodified linesif not query.strip():html_content = """<html><head><title>LLM Search Engine</title><style>body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }.header { text-align: center; margin-bottom: 20px; }.logo { font-size: 36px; font-weight: bold; }.logo span:nth-child(1) { color: #4285f4; } /* Blue */.logo span:nth-child(2) { color: #ea4335; } /* Red */.logo span:nth-child(3) { color: #fbbc05; } /* Yellow */.logo span:nth-child(4) { color: #4285f4; } /* Blue */.logo span:nth-child(5) { color: #34a853; } /* Green */.search-box { max-width: 584px; margin: 0 auto; }.search-box input[type="text"] {width: 100%; padding: 12px 20px; font-size: 16px;border: 1px solid #dfe1e5; border-radius: 24px;box-shadow: 0 1px 6px rgba(32,33,36,0.28);}.search-box input[type="submit"] {background-color: #f8f9fa; border: 1px solid #f8f9fa;border-radius: 4px; color: #3c4043; font-size: 14px;padding: 10px 16px; margin: 11px 4px; cursor: pointer;}.search-box input[type="submit"]:hover {border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);}.search-buttons { text-align: center; }</style></head><body><div class="header"><div class="logo"><span>L</span><span>L</span><span>M</span><span> </span><span>Search</span></div></div><div class="search-box"><form method="get" action="/"><input type="text" name="query" placeholder="Search..."><input type="hidden" name="page" value="1"><div class="search-buttons"><input type="submit" value="LLM Search"><input type="submit" value="I'm Feeling Lucky" disabled></div></form></div></body></html>"""4 unmodified linesif error:html_content = f"""<html><head><title>LLM Search Engine</title><style>body {{ font-family: Arial, sans-serif; margin: 0; padding: 20px; }}.header {{ text-align: center; margin-bottom: 20px; }}.logo {{ font-size: 36px; font-weight: bold; }}.logo span:nth-child(1) {{ color: #4285f4; }}.logo span:nth-child(2) {{ color: #ea4335; }}.logo span:nth-child(3) {{ color: #fbbc05; }}.logo span:nth-child(4) {{ color: #4285f4; }}.logo span:nth-child(5) {{ color: #34a853; }}.search-box {{ max-width: 584px; margin: 0 auto; }}.search-box input[type="text"] {{width: 100%; padding: 12px 20px; font-size: 16px;border: 1px solid #dfe1e5; border-radius: 24px;box-shadow: 0 1px 6px rgba(32,33,36,0.28);}}.search-box input[type="submit"] {{background-color: #f8f9fa; border: 1px solid #f8f9fa;border-radius: 4px; color: #3c4043; font-size: 14px;padding: 10px 16px; margin: 11px 4px; cursor: pointer;}}.search-box input[type="submit"]:hover {{border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);}}.search-buttons {{ text-align: center; }}.error {{ color: red; text-align: center; }}</style></head><body><div class="header"><div class="logo"><span>L</span><span>L</span><span>M</span><span> </span><span>Search</span></div></div><div class="search-box"><form method="get" action="/"><input type="text" name="query" value="{html.escape(query)}"><input type="hidden" name="page" value="1"><div class="search-buttons"><input type="submit" value="LLM Search"><input type="submit" value="I'm Feeling Lucky" disabled></div></form></div><p class="error">{error}</p></body></html>"""8 unmodified linesif start_idx >= len(results):html_content = f"""<html><head><title>LLM Search Engine</title><style>body {{ font-family: Arial, sans-serif; margin: 0; padding: 20px; }}.header {{ text-align: center; margin-bottom: 20px; }}.logo {{ font-size: 36px; font-weight: bold; }}.logo span:nth-child(1) {{ color: #4285f4; }}.logo span:nth-child(2) {{ color: #ea4335; }}.logo span:nth-child(3) {{ color: #fbbc05; }}.logo span:nth-child(4) {{ color: #4285f4; }}.logo span:nth-child(5) {{ color: #34a853; }}.search-box {{ max-width: 584px; margin: 0 auto; }}.search-box input[type="text"] {{width: 100%; padding: 12px 20px; font-size: 16px;border: 1px solid #dfe1e5; border-radius: 24px;box-shadow: 0 1px 6px rgba(32,33,36,0.28);}}.search-box input[type="submit"] {{background-color: #f8f9fa; border: 1px solid #f8f9fa;border-radius: 4px; color: #3c4043; font-size: 14px;padding: 10px 16px; margin: 11px 4px; cursor: pointer;}}.search-box input[type="submit"]:hover {{border: 1px solid #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);}}.search-buttons {{ text-align: center; }}</style></head><body><div class="header"><div class="logo"><span>L</span><span>L</span><span>M</span><span> </span><span>Search</span></div></div><div class="search-box"><form method="get" action="/"><input type="text" name="query" value="{html.escape(query)}"><input type="hidden" name="page" value="1"><div class="search-buttons"><input type="submit" value="LLM Search"><input type="submit" value="I'm Feeling Lucky" disabled></div></form></div><p style="text-align: center;">No more results to display.</p></body></html>"""1 unmodified linepaginated_results = results[start_idx:end_idx]# Generate full HTML page styled like Googlehtml_content = f"""<html><head>2 unmodified linesbody {{font-family: Arial, sans-serif;margin: 0;padding: 0;color: #202124;}}.header {{text-align: center;padding: 20px 0;}}.logo {{font-size: 36px;font-weight: bold;}}.logo span:nth-child(1) {{ color: #4285f4; }}.logo span:nth-child(2) {{ color: #ea4335; }}.logo span:nth-child(3) {{ color: #fbbc05; }}.logo span:nth-child(4) {{ color: #4285f4; }}.logo span:nth-child(5) {{ color: #34a853; }}.search-box {{max-width: 584px;margin: 0 auto 20px;}}.search-box input[type="text"] {{width: 100%;padding: 12px 20px;font-size: 16px;border: 1px solid #dfe1e5;border-radius: 24px;box-shadow: 0 1px 6px rgba(32,33,36,0.28);outline: none;}}.search-box input[type="submit"] {{background-color: #f8f9fa;border: 1px solid #f8f9fa;border-radius: 4px;color: #3c4043;font-size: 14px;padding: 10px 16px;margin: 11px 4px;cursor: pointer;}}.search-box input[type="submit"]:hover {{border: 1px solid #dadce0;box-shadow: 0 1px 2px rgba(0,0,0,0.1);}}.search-buttons {{text-align: center;}}.results {{max-width: 652px;margin: 0 auto;}}.search-result {{margin-bottom: 28px;}}.search-result a {{color: #1a0dab;font-size: 20px;text-decoration: none;}}.search-result a:hover {{2 unmodified lines.search-result .url {{color: #006621;font-size: 14px;line-height: 20px;}}.search-result p {{color: #4d5156;font-size: 14px;line-height: 22px;margin: 0;}}.pagination {{text-align: center;margin: 40px 0;}}.pagination a, .pagination span {{color: #1a0dab;font-size: 14px;margin: 0 8px;text-decoration: none;}}.pagination a:hover {{2 unmodified lines</style></head><body><div class="header"><div class="logo"><span>L</span><span>L</span><span>M</span><span> </span><span>Search</span></div></div><div class="search-box"><form method="get" action="/"><input type="text" name="query" value="{html.escape(query)}"><input type="hidden" name="page" value="1"><div class="search-buttons"><input type="submit" value="LLM Search"><input type="submit" value="I'm Feeling Lucky" disabled></div></form></div><div class="results"><h2 style="font-size: 18px; color: #70757a; margin-bottom: 20px;">Results for '{html.escape(query)}' (Page {page} of {total_pages})</h2>"""for result in paginated_results:
app.py+202-53