Flask routing binds a view function to a URL rule
Answer: The @app.route decorator binds a view function to a URL. You can make parts of the URL dynamic with <variable_name>, and optionally a converter such as <int:post_id>.
Rules and converters
Built-in converter types include string (the default, no slashes), int, float, path (slashes allowed), and uuid. A trailing slash on the rule changes redirect behavior: a rule that ends in a slash is treated like a folder and redirects the slash-less form to the canonical URL; a rule without a trailing slash is treated like a file, and the slashed form returns 404.
The decorator in source
route decorates a view function and then calls add_url_rule. If you omit endpoint, the endpoint name defaults to the view function's name. add_url_rule is the method that registers the rule used both to route incoming requests and to build URLs.
See also
Claims
- id: C1 claim: The route decorator binds a function to a URL. source: S1 evidence: "decorator to bind a function to a URL."
- id: C2 claim: Variable URL sections are marked with angle-bracket names. source: S1 evidence: "add variable sections to a URL by marking sections with"
- id: C3 claim: route registers the view with a URL rule and delegates to add_url_rule. source: S2 evidence: "Decorate a view function to register it with the given URL"
- id: C4 claim: add_url_rule registers a rule for routing requests and building URLs. source: S2 evidence: "Register a rule for routing incoming requests and building"
Sources
- [S1] Quickstart. Flask docs. https://flask.palletsprojects.com/en/stable/quickstart/ . License: BSD-3-Clause. Accessed 2026-11-11.
- [S2] Flask.route and add_url_rule. Flask source. https://github.com/pallets/flask/blob/main/src/flask/sansio/scaffold.py . License: BSD-3-Clause. Accessed 2026-11-11.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: Flask documentation and source (pallets/flask): Copyright 2010 Pallets; BSD-3-Clause (https://raw.githubusercontent.com/pallets/flask/main/LICENSE.txt). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Flask docs and Flask source (pallets/flask), BSD-3-Clause (https://raw.githubusercontent.com/pallets/flask/main/LICENSE.txt). Notices: Flask documentation and source (pallets/flask): Copyright 2010 Pallets; BSD-3-Clause (https://raw.githubusercontent.com/pallets/flask/main/LICENSE.txt).
Cite this
iinventedlight. 2026. "Flask routing binds a view function to a URL rule." iinventedlight Library, iil:note:cf60f985, version of 2026-11-11. https://iinventedlight.com/library/notes/flask-routing/. License: CC-BY-4.0.
@misc{iil_note_cf60f985,
author = {{iinventedlight}},
title = {{Flask routing binds a view function to a URL rule}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-11},
url = {https://iinventedlight.com/library/notes/flask-routing/},
note = {Permanent ID iil:note:cf60f985. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/flask-routing.md.