I’m working on an auto-fill application, and to make it work, I need to receive requests in real time. For instance, if a user starts typing a query like ‘machine lear’, I want the application to fetch suggestions before the user hits the submit button.
Here is the code:
@app.route('/search', methods=['GET','POST'])
def search():
user_query = request.args.get('query')
if user_query:
user_query = check_words(user_query)
results = algorithm_v3(user_query, word_vectors, nlp, df_at)
results = df.iloc[results]
user_query_list = user_query.split()
return render_template('results.html', results=results, user_query=user_query_list, search_query=user_query)
else:
return "User did'nt input anything."
New contributor
Dzotsee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.