0

I currently have a route such as

@mod.route("/server/power/<int:path>", methods=["GET"])
@mod.route("/server/resize/<int:path>", methods=["GET", "POST"])
@mod.route("/server/history/<int:path>", methods=["GET"])
@mod.route("/server/destroy/<int:path>", methods=["GET"])
@mod.route("/server/<int:path>", methods=["GET"])
@login_required
def server(path=None):
# do stuff
    return "ok"

The problem is I'm trying to get the url_for to return this route upon being called

@mod.route("/server/<int:path>", methods=["GET"])

But when I do this:

url_for('admin.server', path=server_id)

It returns the url for

@mod.route("/server/resize/<int:path>", methods=["GET", "POST"])

How do I get it to return the base route:

@mod.route("/server/<int:path>", methods=["GET"])
nadermx
  • 2,596
  • 7
  • 31
  • 66

1 Answers1

0

You can name specific routes, so by adding the endpoint to the route I was able to use url_for to the specific route

@mod.route("/server/power/<int:path>", methods=["GET"])
@mod.route("/server/resize/<int:path>", methods=["GET", "POST"])
@mod.route("/server/history/<int:path>", methods=["GET"])
@mod.route("/server/destroy/<int:path>", methods=["GET"])
@mod.route("/server/<int:path>", methods=["GET"], endpoint='server_default')
@login_required
def server(path=None):
    return 'ok'

So when I called url_for('admin.server_default', path=server_id) it built the right url

nadermx
  • 2,596
  • 7
  • 31
  • 66