Categories
Python Answers

How to get list of all routes defined in the Python Flask app?

Spread the love

Sometimes, we want to get list of all routes defined in the Python Flask app.

In this article, we’ll look at how to get list of all routes defined in the Python Flask app.

How to get list of all routes defined in the Python Flask app?

To get list of all routes defined in the Python Flask app, we can use the app.url_map property.

For instance, we write

from app import app

# ...

print(app.url_map)

to print the list of routes in our app with print(app.url_map).

Conclusion

To get list of all routes defined in the Python Flask app, we can use the app.url_map property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *