← All notes

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

Sources

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

Permanent ID: iil:note:cf60f985

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.},
}

Markdown

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.