Get list of all routes defined in the Flask app
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When a Flask application grows beyond a few endpoints, it becomes useful to inspect the full route table. A route listing helps with debugging, documentation, permission reviews, and confirming that blueprints were registered the way you expected.
The Route Table Lives in app.url_map
Flask stores registered URL rules in app.url_map. The easiest programmatic way to list routes is to iterate over those rules and print the path, endpoint name, and allowed methods.
Each rule object gives you useful metadata:
- '
rule.ruleis the URL pattern.' - '
rule.endpointis the internal endpoint name, usually the view function name.' - '
rule.methodsis the set of HTTP methods allowed for that route.'
That is enough for most debugging and internal documentation tasks.
Example Output and What It Means
A route table from the code above might look like this:
Notice the static route. Flask adds it automatically unless static serving is disabled. Developers often forget about it and then wonder why an unexpected route appears in the output.
Using the Flask CLI
If you want a quick route listing without writing any code, Flask also provides a CLI command:
This is often the fastest option while developing locally. It prints a table of routes after Flask imports the application. For app factory setups, pass the correct import path so Flask can create the app instance first.
Filtering Routes for Documentation
In a real project, the full route table may include internal endpoints, static files, or methods you do not care about. Filtering the rules is simple:
This kind of filtering is useful when generating internal docs or checking only API endpoints.
Blueprints Work the Same Way
If your application uses blueprints, their routes still end up in the main app's URL map after registration. Blueprint endpoints are usually prefixed, which makes them easy to identify.
For example, a route inside a blueprint named admin may appear with an endpoint like admin.dashboard. That prefix helps you group routes by module when printing or exporting them.
Common Pitfalls
One common surprise is that HEAD and OPTIONS appear even when you only declared GET. Flask adds some methods automatically, so filter them out if you want a cleaner list.
Another issue is forgetting that the CLI must be able to import your app. If flask routes shows nothing useful, make sure the --app argument points to the correct module or factory.
Be aware that listing routes does not tell you everything about access control. A route can exist while still requiring authentication, role checks, or other middleware-style guards inside the view logic.
Finally, do not confuse endpoint names with URLs. rule.endpoint is the internal identifier used by url_for, while rule.rule is the actual URL pattern.
Summary
- Flask keeps registered routes in
app.url_map. - Use
app.url_map.iter_rules()to inspect endpoints, methods, and URL patterns programmatically. - The
flask --app ... routescommand is a quick built-in way to print the route table. - Expect automatic entries such as the
staticendpoint and methods likeHEADandOPTIONS. - Blueprint routes appear in the same URL map after registration, usually with prefixed endpoint names.

