Return 503 if response is blocked by captcha
Also added in a slight modification to the dark theme style, which should only apply the border radius in the header. Closes #226main
parent
62a9b9e949
commit
083c3758a1
|
@ -229,6 +229,9 @@ def search():
|
||||||
# the element key can be regenerated
|
# the element key can be regenerated
|
||||||
app.user_elements[session['uuid']] = elements
|
app.user_elements[session['uuid']] = elements
|
||||||
|
|
||||||
|
# Return 503 if temporarily blocked by captcha
|
||||||
|
resp_code = 503 if has_captcha(str(response)) else 200
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'display.html',
|
'display.html',
|
||||||
query=urlparse.unquote(query),
|
query=urlparse.unquote(query),
|
||||||
|
@ -242,7 +245,7 @@ def search():
|
||||||
query=urlparse.unquote(query),
|
query=urlparse.unquote(query),
|
||||||
search_type=search_util.search_type,
|
search_type=search_util.search_type,
|
||||||
mobile=g.user_request.mobile)
|
mobile=g.user_request.mobile)
|
||||||
if 'isch' not in search_util.search_type else ''))
|
if 'isch' not in search_util.search_type else '')), resp_code
|
||||||
|
|
||||||
|
|
||||||
@app.route('/config', methods=['GET', 'POST', 'PUT'])
|
@app.route('/config', methods=['GET', 'POST', 'PUT'])
|
||||||
|
|
|
@ -67,7 +67,6 @@ select {
|
||||||
|
|
||||||
#search-bar {
|
#search-bar {
|
||||||
border: 2px solid var(--whoogle-dark-accent) !important;
|
border: 2px solid var(--whoogle-dark-accent) !important;
|
||||||
border-radius: 8px;
|
|
||||||
color: var(--whoogle-dark-text) !important;
|
color: var(--whoogle-dark-text) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
|
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
|
||||||
style="background-color: {{ 'var(--whoogle-dark-result-bg)' if config.dark else 'var(--whoogle-result-bg)' }} !important;
|
style="background-color: {{ 'var(--whoogle-dark-result-bg)' if config.dark else 'var(--whoogle-result-bg)' }} !important;
|
||||||
color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }};
|
color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }};
|
||||||
border: {{ '2px solid var(--whoogle-dark-accent)' if config.dark else '' }};"
|
border: {{ '2px solid var(--whoogle-dark-accent)' if config.dark else '' }}; border-radius: 8px;"
|
||||||
spellcheck="false" type="text" value="{{ query }}">
|
spellcheck="false" type="text" value="{{ query }}">
|
||||||
<input name="tbm" value="{{ search_type }}" style="display: none">
|
<input name="tbm" value="{{ search_type }}" style="display: none">
|
||||||
<input type="submit" style="display: none;">
|
<input type="submit" style="display: none;">
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
spellcheck="false" type="text" value="{{ query }}"
|
spellcheck="false" type="text" value="{{ query }}"
|
||||||
style="background-color: {{ 'var(--whoogle-dark-result-bg)' if config.dark else 'var(--whoogle-result-bg)' }} !important;
|
style="background-color: {{ 'var(--whoogle-dark-result-bg)' if config.dark else 'var(--whoogle-result-bg)' }} !important;
|
||||||
color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }};
|
color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }};
|
||||||
border: {{ '2px solid var(--whoogle-dark-accent)' if config.dark else '' }};">
|
border: {{ '2px solid var(--whoogle-dark-accent)' if config.dark else '' }}; border-radius: 8px;">
|
||||||
<input name="tbm" value="{{ search_type }}" style="display: none">
|
<input name="tbm" value="{{ search_type }}" style="display: none">
|
||||||
<input type="submit" style="display: none;">
|
<input type="submit" style="display: none;">
|
||||||
<div class="sc"></div>
|
<div class="sc"></div>
|
||||||
|
|
|
@ -8,6 +8,7 @@ from typing import Any, Tuple
|
||||||
import os
|
import os
|
||||||
|
|
||||||
TOR_BANNER = '<hr><h1 style="text-align: center">You are using Tor</h1><hr>'
|
TOR_BANNER = '<hr><h1 style="text-align: center">You are using Tor</h1><hr>'
|
||||||
|
CAPTCHA = 'div class="g-recaptcha"'
|
||||||
|
|
||||||
|
|
||||||
def needs_https(url: str) -> bool:
|
def needs_https(url: str) -> bool:
|
||||||
|
@ -30,6 +31,10 @@ def needs_https(url: str) -> bool:
|
||||||
return (is_heroku and is_http) or (https_only and is_http)
|
return (is_heroku and is_http) or (https_only and is_http)
|
||||||
|
|
||||||
|
|
||||||
|
def has_captcha(site_contents: str) -> bool:
|
||||||
|
return CAPTCHA in site_contents
|
||||||
|
|
||||||
|
|
||||||
class Search:
|
class Search:
|
||||||
"""Search query preprocessor - used before submitting the query or
|
"""Search query preprocessor - used before submitting the query or
|
||||||
redirecting to another site
|
redirecting to another site
|
||||||
|
|
Loading…
Reference in New Issue