Skip to content
Advertisement

Get list of all routes defined in the Flask app

I have a complex Flask-based web app. There are lots of separate files with view functions. Their URLs are defined with the @app.route('/...') decorator. Is there a way to get a list of all the routes that have been declared throughout my app? Perhaps there is some method I can call on the app object?

Advertisement

Answer

All the routes for an application are stored on app.url_map which is an instance of werkzeug.routing.Map. You can iterate over the Rule instances by using the iter_rules method:

JavaScript

See Display links to new webpages created for a bit more information.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement