Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

add optional request with GET method for search and results pages

Matej Cotman32e98967b76d
diff --git a/searx/templates/preferences.html b/searx/templates/preferences.html
index 582305a1b..eeb86577f 100644
--- a/searx/templates/preferences.html
+++ b/searx/templates/preferences.html
@@ -43,6 +43,15 @@
</select>
</p>
</fieldset>
+ <fieldset>
+ <legend>{{ _('Method') }}</legend>
+ <p>
+ <select name='method'>
+ <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
+ <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
+ </select>
+ </p>
+ </fieldset>
<fieldset>
<legend>{{ _('Currently used search engines') }}</legend>
diff --git a/searx/templates/results.html b/searx/templates/results.html
index 8094e96b6..97c2696c8 100644
--- a/searx/templates/results.html
+++ b/searx/templates/results.html
@@ -10,7 +10,7 @@
{% if suggestions %}
<div id="suggestions"><span>{{ _('Suggestions') }}</span>
{% for suggestion in suggestions %}
- <form method="post" action="{{ url_for('index') }}">
+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<input type="hidden" name="q" value="{{ suggestion }}">
<input type="submit" value="{{ suggestion }}" />
</form>
@@ -25,7 +25,7 @@
<div id="apis">
{{ _('Download results') }}
{% for output_type in ('csv', 'json', 'rss') %}
- <form method="post" action="{{ url_for('index') }}">
+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<div class="left">
<input type="hidden" name="q" value="{{ q }}" />
<input type="hidden" name="format" value="{{ output_type }}" />
@@ -52,7 +52,7 @@
{% if paging %}
<div id="pagination">
{% if pageno > 1 %}
- <form method="post" action="{{ url_for('index') }}">
+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<div class="left">
<input type="hidden" name="q" value="{{ q }}" />
{% for category in selected_categories %}
@@ -63,7 +63,7 @@
</div>
</form>
{% endif %}
- <form method="post" action="{{ url_for('index') }}">
+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<div class="left">
{% for category in selected_categories %}
<input type="hidden" name="category_{{ category }}" value="1"/>
diff --git a/searx/templates/search.html b/searx/templates/search.html
index 95e312e5a..30d1568cf 100644
--- a/searx/templates/search.html
+++ b/searx/templates/search.html
@@ -1,4 +1,4 @@
-<form method="post" action="{{ url_for('index') }}" id="search_form">
+<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form">
<div id="search_wrapper">
<input type="text" placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/>
<input type="submit" value="search" id="search_submit" />
diff --git a/searx/webapp.py b/searx/webapp.py
index 1058d9e65..a9de3255e 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -123,6 +123,8 @@ def render(template_name, **kwargs):
if not 'autocomplete' in kwargs:
kwargs['autocomplete'] = autocomplete
+ kwargs['method'] = request.cookies.get('method', 'POST')
+
return render_template(template_name, **kwargs)
@@ -295,6 +297,7 @@ def preferences():
selected_categories = []
locale = None
autocomplete = ''
+ method = 'POST'
for pd_name, pd in request.form.items():
if pd_name.startswith('category_'):
category = pd_name[9:]
@@ -309,6 +312,8 @@ def preferences():
pd in (x[0] for
x in language_codes)):
lang = pd
+ elif pd_name == 'method':
+ method = pd
elif pd_name.startswith('engine_'):
engine_name = pd_name.replace('engine_', '', 1)
if engine_name in engines:
@@ -348,6 +353,8 @@ def preferences():
max_age=cookie_max_age
)
+ resp.set_cookie('method', method, max_age=cookie_max_age)
+
return resp
return render('preferences.html',
locales=settings['locales'],