/search_results/%2Fthis%2Fis%2Fmy%2Fsearch
isn't opening because werkzeug router is decoding it internally before mapping it to a view and it is resulting in /search_results//this/is/my/search
which is not compatible with the pattern /search_results/<search>
in your endpoint, hence the 404 error.
You can encode the string twice with javascript (which would result in %252Fthis%252Fis%252Fmy%252Fsearch
) and /search_results/%252Fthis%252Fis%252Fmy%252Fsearch
will be mapped correctly to your view function. Note that flask will automatically decode it once so you'll need to decode the value received in search
parameter once again.
The other (and cleaner) way it to pass the input string as URL query parameters like /search?q=this/is/my/search
. To achieve this, modify the endpoint pattern like so:
@maverick.route('/search_results', methods= ['GET', 'POST'])
def generateSearchResults():
search_string = request.args.get('q')