From 89a2f78d297432f01e87dc4797e5f44a2bb2471d Mon Sep 17 00:00:00 2001 From: Ben Cohen Date: Sun, 28 Jul 2019 19:59:58 -0400 Subject: search! --- app.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index a610097..beee1d5 100644 --- a/app.py +++ b/app.py @@ -130,15 +130,15 @@ def get_all_beers(): return jsonify([orig_term_map[x] for x in search(q)]) # return jsonify(names[0:20]) -@app.route('/search', methods=['POST']) -def search(): - q = request.form.get('q') - if not q: - return redirect('/') - brewery, beer_name = q.split(' — ') - print('SEARCHING: ', q) - beer_id, brewery_id = name_list[q].split('-') - return redirect(url_for('get_beer_details', beer_id=beer_id, brewery_id=brewery_id)) +# @app.route('/search', methods=['POST']) +# def search(): +# q = request.form.get('q') +# if not q: +# return redirect('/') +# brewery, beer_name = q.split(' — ') +# print('SEARCHING: ', q) +# beer_id, brewery_id = name_list[q].split('-') +# return redirect(url_for('get_beer_details', beer_id=beer_id, brewery_id=brewery_id)) @@ -152,7 +152,7 @@ def search(query): matches = [x for x in search_words if term in x] # print(matches) for m in matches: - all_matches[m] += 1/len(matches) + all_matches[m] += 1/len(matches)/len(m) return sorted(all_matches, key=lambda x: all_matches[x], reverse=True)[:10] -- cgit v1.2.3