I am trying to implement a basic search bar functionality to my site.
I will process the actual search on my database later but at the moment I am trying to just send the request, which will simply be a string from my search bar to my search route.
I have my search bar form:
<form class="form-inline" action="{{ url_for('search') }}">
<input class="form-control" type="search" placeholder="Search">
<button class="btn btn-primary" type="submit">Search!</button>
</form>
and my route
@app.route('/search', methods=['GET', 'POST'])
def search():
user_search = request.args['search']
return render_template('results.html', search=user_search)
When I use my search bar I get the following error:
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 'search'
I do not understand where I am going wrong.