diff options
author | asciimoo <asciimoo@gmail.com> | 2013-10-20 22:21:34 +0200 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2013-10-20 22:21:34 +0200 |
commit | e75432c505be609441b6a22c4e2687e6bd758a0d (patch) | |
tree | ab32ec7e52b98ff902c65aec122a91d7085e9674 /searx | |
parent | 799eceeee6544bc9242c2d75bcbc142e1385fa82 (diff) | |
download | searxng-e75432c505be609441b6a22c4e2687e6bd758a0d.tar.gz searxng-e75432c505be609441b6a22c4e2687e6bd758a0d.zip |
[enh] HTTP GET support
Diffstat (limited to 'searx')
-rw-r--r-- | searx/webapp.py | 13 |
1 files 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' |