List all routes in a Flask app (app.url_map and flask routes)
Codemia Knowledge Hub ·
Flask stores every registered URL rule in app.url_map. Iterate over app.url_map.iter_rules() to print each route's path, endpoint and methods, or run flask --app app routes to get the table without writing code. A route listing helps with debugging, documentation, permission reviews and checking that blueprints registered as expected.
Iterate app.url_map.iter_rules()
Each rule object carries 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.
Example output, including the static route
The code above prints something like:
Flask adds the static route automatically unless static serving is disabled, which is why an unexpected route often appears in the output.
The flask routes CLI command
This is often the fastest option during local development. It prints a table of routes after Flask imports the application. For app factories, pass the correct import path so Flask can create the app first.
Filtering routes for documentation
The full table may include static files, internal endpoints or methods you do not care about. Filter the rules:
This is useful for generating internal docs or checking only API endpoints.
Blueprint routes
Blueprint routes end up in the main app's URL map after registration. Their endpoints are usually prefixed: a route in a blueprint named admin may appear as admin.dashboard, which makes it easy to group routes by module.
Surprises in the route list
HEADandOPTIONSappear even when you only declaredGET, because Flask adds some methods automatically. Filter them out for a cleaner list.- If
flask routesshows nothing useful, make sure the--appargument points to the correct module or factory. - A route listing says nothing about access control. A route may still require authentication, role checks or other guards inside the view.
- Endpoint names are not URLs.
rule.endpointis the identifier used byurl_for, whilerule.ruleis the URL pattern.
Related reading
- Get list of JSON objects with Spring RestTemplate
- Get Public IP Address on current EC2 Instance
- Get Service selectors with K8s Python client
- Get the bounding box coordinates in the TensorFlow object detection API tutorial
- Get list of pandas dataframe columns based on data type
- Get Month name from month number
- Get the data received in a Flask request
- Get the full call stack trace of http calls
System design interview problems on this topic
- Design a Load Balancer: solution and walkthrough
- Design a Domain Name System: solution and walkthrough
- Design a Global Content Distribution Network: solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.