Create dynamic URLs in Flask with url_for()

It takes keyword arguments for the variables:

url_for('add', variable=foo)
url_for('remove', variable=foo)

The flask-server would have functions:

@app.route('/<variable>/add', methods=['GET', 'POST'])
def add(variable):

@app.route('/<variable>/remove', methods=['GET', 'POST'])
def remove(variable):

Leave a Comment