So I have a method that is accessible by multiple routes:
@app.route(\"/canonical/path/\")
@app.route(\"/alternate/path/\")
def foo():
return \"hi!\"
Additionally, for those using a catch all route constructed with variables: Flask will correctly create the url path if url_for is passed a dictionary containing the variables.
For example...
app.py:
app.route('/')
app.route('//')
def catch_all(pattern1, pattern2=None):
return render_template('template.html', p1=pattern1, p2=pattern2)
app.route('/test')
def test_routing:
args = {'pattern1': 'Posts', 'pattern2': 'create'}
return render_template('test.html', args=args)
test.html:
click here
When you click on the 'click here' link, you will be directed to the 'Posts/create' route.