forked from Ponysearch/Ponysearch
adding initial code for backend-part of autocompleter
including test-code
This commit is contained in:
parent
b5c695c6f5
commit
8abf4ab993
2 changed files with 19 additions and 2 deletions
|
@ -1,8 +1,7 @@
|
||||||
window.addEvent('domready', function() {
|
window.addEvent('domready', function() {
|
||||||
new Autocompleter.Request.JSON('q', '/', {
|
new Autocompleter.Request.JSON('q', '/autocompleter', {
|
||||||
postVar:'q',
|
postVar:'q',
|
||||||
postData:{
|
postData:{
|
||||||
'autocompleter': 1,
|
|
||||||
'format': 'json'
|
'format': 'json'
|
||||||
},
|
},
|
||||||
ajaxOptions:{
|
ajaxOptions:{
|
||||||
|
|
|
@ -221,6 +221,24 @@ def about():
|
||||||
return render('about.html')
|
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'])
|
@app.route('/preferences', methods=['GET', 'POST'])
|
||||||
def preferences():
|
def preferences():
|
||||||
"""Render preferences page.
|
"""Render preferences page.
|
||||||
|
|
Loading…
Reference in a new issue