logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git
commit: 8abf4ab993cd4a81dc97f85fb8a30a6c875221f7
parent b5c695c6f525eb692d3e476817b49d2661ba2d25
Author: Thomas Pointhuber <thomas.pointhuber@gmx.at>
Date:   Thu, 20 Mar 2014 10:28:24 +0100

adding initial code for backend-part of autocompleter

including test-code

Diffstat:

Msearx/static/js/searx.js3+--
Msearx/webapp.py18++++++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/searx/static/js/searx.js b/searx/static/js/searx.js @@ -1,8 +1,7 @@ window.addEvent('domready', function() { - new Autocompleter.Request.JSON('q', '/', { + new Autocompleter.Request.JSON('q', '/autocompleter', { postVar:'q', postData:{ - 'autocompleter': 1, 'format': 'json' }, ajaxOptions:{ diff --git a/searx/webapp.py b/searx/webapp.py @@ -221,6 +221,24 @@ def about(): return render('about.html') +@app.route('/autocompleter', methods=['GET', 'POST']) +def autocompleter(): + """Return autocompleter results""" + request_data = {} + + if request.method == 'POST': + request_data = request.form + else: + request_data = request.args + + # TODO fix XSS-vulnerability, remove test code + autocompleter.querry = request_data.get('q') + autocompleter.results = [autocompleter.querry] + + return Response(json.dumps(autocompleter.results), + mimetype='application/json') + + @app.route('/preferences', methods=['GET', 'POST']) def preferences(): """Render preferences page.