diff options
author | Ben Cohen <ben@kensho.com> | 2019-07-28 19:59:58 -0400 |
---|---|---|
committer | Ben Cohen <ben@kensho.com> | 2019-07-28 19:59:58 -0400 |
commit | 89a2f78d297432f01e87dc4797e5f44a2bb2471d (patch) | |
tree | d5e5aad9cd98d4eced22840706bebd4e332d1e7d | |
parent | 88c2dc94bba23097e2a573b294dd7e585644d58e (diff) |
search!
-rw-r--r-- | app.py | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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] |