routes_command() — flask Function Reference
Architecture documentation for the routes_command() function in cli.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD e98c6248_deab_6de5_4dbf_70a18ad3d795["routes_command()"] ae3e7759_c80d_adef_bd99_d069d65ed2f2["cli.py"] e98c6248_deab_6de5_4dbf_70a18ad3d795 -->|defined in| ae3e7759_c80d_adef_bd99_d069d65ed2f2 style e98c6248_deab_6de5_4dbf_70a18ad3d795 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/cli.py lines 1061–1107
def routes_command(sort: str, all_methods: bool) -> None:
"""Show all registered routes with endpoints and methods."""
rules = list(current_app.url_map.iter_rules())
if not rules:
click.echo("No routes were registered.")
return
ignored_methods = set() if all_methods else {"HEAD", "OPTIONS"}
host_matching = current_app.url_map.host_matching
has_domain = any(rule.host if host_matching else rule.subdomain for rule in rules)
rows = []
for rule in rules:
row = [
rule.endpoint,
", ".join(sorted((rule.methods or set()) - ignored_methods)),
]
if has_domain:
row.append((rule.host if host_matching else rule.subdomain) or "")
row.append(rule.rule)
rows.append(row)
headers = ["Endpoint", "Methods"]
sorts = ["endpoint", "methods"]
if has_domain:
headers.append("Host" if host_matching else "Subdomain")
sorts.append("domain")
headers.append("Rule")
sorts.append("rule")
try:
rows.sort(key=itemgetter(sorts.index(sort)))
except ValueError:
pass
rows.insert(0, headers)
widths = [max(len(row[i]) for row in rows) for i in range(len(headers))]
rows.insert(1, ["-" * w for w in widths])
template = " ".join(f"{{{i}:<{w}}}" for i, w in enumerate(widths))
for row in rows:
click.echo(template.format(*row))
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does routes_command() do?
routes_command() is a function in the flask codebase, defined in src/flask/cli.py.
Where is routes_command() defined?
routes_command() is defined in src/flask/cli.py at line 1061.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free