My application often uses URL-encoded strings as a URL parameter. Often these lines look like slash tracks. The IE /file/foo. In the bulb, I have an endpoint that takes a path parameter where I send the URL of the encoded path. So I have something similar:
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 fine if I find this URL:
http://localhost:5000/blah/cats%2F
returns:
GOT: cats/
But the leading slash with% 2F fails with 404 in the case of GET and 405 in the case of POST. In other words, these are 404s:
http://localhost:5000/blah/%2Fcats
In my research on this issue, I was lucky here that the URL encoding was sufficient to fix the problem. However, it is not.