My application frequently takes URL encoded strings as a URL parameter. Often these strings look like paths with a leading slash. IE
/file/foo. In flask, I have an endpoint that takes a path parameter that I send a URL encoded path to. So I have something that looks like:
import flask app = flask.Flask("Hello World") @app.route("/blah/<path:argument>", methods=["GET"]) def foo(argument): return "GOT: %s" % argument if __name__ == "__main__": app.run(debug=True)
This works great if I visit this URL:
http://localhost:5000/blah/cats%2F returns: GOT: cats/
But a leading slash with %2F fails with 404 in the case of GET and 405 in the case of POST. In other words, this 404s:
In my research on this problem, I was lead to believe here that URL encoding was sufficient to sole the problem. However that doesn't appear to be the case.