How do I use url_for if my method has multiple route annotations?
问题 So I have a method that is accessible by multiple routes: @app.route("/canonical/path/") @app.route("/alternate/path/") def foo(): return "hi!" Now, how can I call url_for("foo") and know that I will get the first route? 回答1: Ok. It took some delving into the werkzeug.routing and flask.helpers.url_for code, but I've figured out. You just change the endpoint for the route (in other words, you name your route) @app.route("/canonical/path/", endpoint="foo-canonical") @app.route("/alternate/path/