Menu Close

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

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.

Posted in Python, Python Answers