mirror of
https://github.com/searxng/searxng.git
synced 2024-11-29 14:11:02 +00:00
[enh] HTTP GET support
This commit is contained in:
parent
799eceeee6
commit
e75432c505
1 changed files with 7 additions and 6 deletions
|
@ -60,12 +60,13 @@ def render(template_name, **kwargs):
|
||||||
def index():
|
def index():
|
||||||
global categories
|
global categories
|
||||||
if request.method=='POST':
|
if request.method=='POST':
|
||||||
if not request.form.get('q'):
|
request_data = request.form
|
||||||
flash('Wrong post data')
|
else:
|
||||||
return render('index.html')
|
request_data = request.args
|
||||||
|
if request_data.get('q'):
|
||||||
selected_engines = []
|
selected_engines = []
|
||||||
selected_categories = []
|
selected_categories = []
|
||||||
for pd_name,pd in request.form.items():
|
for pd_name,pd in request_data.items():
|
||||||
if pd_name.startswith('category_'):
|
if pd_name.startswith('category_'):
|
||||||
category = pd_name[9:]
|
category = pd_name[9:]
|
||||||
if not category in categories:
|
if not category in categories:
|
||||||
|
@ -81,9 +82,9 @@ def index():
|
||||||
if not len(selected_engines):
|
if not len(selected_engines):
|
||||||
selected_categories.append('general')
|
selected_categories.append('general')
|
||||||
selected_engines.extend(x.name for x in categories['general'])
|
selected_engines.extend(x.name for x in categories['general'])
|
||||||
query = request.form['q'].encode('utf-8')
|
query = request_data['q'].encode('utf-8')
|
||||||
results = search(query, request, selected_engines)
|
results = search(query, request, selected_engines)
|
||||||
if request.form.get('format') == 'json':
|
if request_data.get('format') == 'json':
|
||||||
# TODO HTTP headers
|
# TODO HTTP headers
|
||||||
return json.dumps({'query': query, 'results': results})
|
return json.dumps({'query': query, 'results': results})
|
||||||
template = render('results.html'
|
template = render('results.html'
|
||||||
|
|
Loading…
Reference in a new issue