From b369442e41b9538b0de9dcb01b6012f6fea6aee6 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 10 Jun 2018 19:22:24 +0200 Subject: [PATCH] views --- app/views.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/views.py b/app/views.py index 7c11b44..482d0f0 100755 --- a/app/views.py +++ b/app/views.py @@ -20,7 +20,7 @@ import time from csv import DictWriter, DictReader import io from sqlalchemy.inspection import inspect -import autocomplete +#import autocomplete import sys import os @@ -399,7 +399,7 @@ def show_instances(): @app.route('/books', methods= ['POST','GET']) def show_books(): - autocomplete.load() #Train markov model once, for autocomplete in search + #autocomplete.load() #Train markov model once, for autocomplete in search books = db.session.query(Book).all() search = SearchForm(request.form) @@ -435,28 +435,28 @@ def search_results(searchtype, query): return render_template('results.html', form=search, books=results, books_all=random_order, searchtype=search.select.data, query=query) ## Search - autocomplete -autocomplete_suggestions = [] -autocomplete.load() #Train markov model once, for autocomplete in search - -@app.route('/autocomplete_suggestions', methods=['GET', 'POST']) -def test1(): - if request.method == 'POST': - query = request.form['search'] - query_tokenized = query.lower().split() - print(query_tokenized) - word_1 = query_tokenized[-2] - word_2 = query_tokenized[-1] - #print(word_1) - autocomplete_output = autocomplete.predict(word_1 , word_2) - autocomplete_suggestions.clear() - for suggestion, score in autocomplete_output: - autocomplete_suggestions.append(suggestion) - - session['autocomplete_suggestions'] = str(autocomplete_suggestions) - - print(session['autocomplete_suggestions']) - - return Response(json.dumps(session['autocomplete_suggestions']), mimetype='application/json') +#autocomplete_suggestions = [] +#autocomplete.load() #Train markov model once, for autocomplete in search + +# @app.route('/autocomplete_suggestions', methods=['GET', 'POST']) +# def test1(): +# if request.method == 'POST': +# query = request.form['search'] +# query_tokenized = query.lower().split() +# print(query_tokenized) +# word_1 = query_tokenized[-2] +# word_2 = query_tokenized[-1] +# #print(word_1) +# autocomplete_output = autocomplete.predict(word_1 , word_2) +# autocomplete_suggestions.clear() +# for suggestion, score in autocomplete_output: +# autocomplete_suggestions.append(suggestion) +# +# session['autocomplete_suggestions'] = str(autocomplete_suggestions) +# +# print(session['autocomplete_suggestions']) +# +# return Response(json.dumps(session['autocomplete_suggestions']), mimetype='application/json') ## STACKS!