From e75432c505be609441b6a22c4e2687e6bd758a0d Mon Sep 17 00:00:00 2001 From: asciimoo Date: Sun, 20 Oct 2013 22:21:34 +0200 Subject: [PATCH] [enh] HTTP GET support --- searx/webapp.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index a5b5609d4..517633ac6 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -60,12 +60,13 @@ def render(template_name, **kwargs): def index(): global categories if request.method=='POST': - if not request.form.get('q'): - flash('Wrong post data') - return render('index.html') + request_data = request.form + else: + request_data = request.args + if request_data.get('q'): selected_engines = [] selected_categories = [] - for pd_name,pd in request.form.items(): + for pd_name,pd in request_data.items(): if pd_name.startswith('category_'): category = pd_name[9:] if not category in categories: @@ -81,9 +82,9 @@ def index(): if not len(selected_engines): selected_categories.append('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) - if request.form.get('format') == 'json': + if request_data.get('format') == 'json': # TODO HTTP headers return json.dumps({'query': query, 'results': results}) template = render('results.html'