0Pricing
Flask Academy · Lesson

Trailing Slashes and Redirect Behavior

Understand canonical URLs and automatic redirects.

One Slash Changes Everything

To Flask, /about and /about/ can be two different things. That tiny trailing slash decides how a route matches and whether a redirect happens.

Route Defined With a Slash

When your route ends in a slash, it behaves like a folder. Visiting /docs/ works, and /docs gets redirected to the slashed version. 📁

@app.route('/docs/')
def docs():
    return 'Docs'

All lessons in this course

  1. Capture Variables from the Path
  2. Type Converters: int, float, string, path
  3. Build URLs with url_for
  4. Trailing Slashes and Redirect Behavior
← Back to Flask Academy