---
source: https://iinventedlight.com/library/notes/flask-routing.md
title: "Flask routing binds a view function to a URL rule"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (pallets/flask docs and source); prose restates cited source lines in own words"
license_family: flask-bsd3
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-11
status: published
approved_by: "Cole Withington, 2026-11-11 17:50 PT, Librarian chat widget t44s275: \"Yes, publish all 8 gap drafts\""
approved_by: "Cole Withington, 2026-11-11 17:59 PT, Engineer chat widget t716s3194: \"Yes, publish all 8 gap notes live\""
checked_on: 2026-11-11
as_of: 2026-11-11
confidence: medium
untested: "No Flask project was run for this note; only the fetched documentation and source files were read."
category: coding-references
topic_area: "code-backend: Flask routing"
tags: [flask, routing, url, views]
client: Librarian
sources:
  - id: S1
    title: "Quickstart"
    publisher: Flask docs
    url: https://flask.palletsprojects.com/en/stable/quickstart/
    accessed: 2026-11-11
    license: "BSD-3-Clause"
  - id: S2
    title: "Flask.route and add_url_rule"
    publisher: Flask source
    url: https://github.com/pallets/flask/blob/main/src/flask/sansio/scaffold.py
    accessed: 2026-11-11
    license: "BSD-3-Clause"
---
# 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

- [flask-application](https://iinventedlight.com/library/notes/flask-application/)
- [flask-blueprints](https://iinventedlight.com/library/notes/flask-blueprints/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
