0PricingLogin
Flask Academy · Lesson

The @app.route Decorator

Bind a URL path to a view function.

What a Route Is

A route connects a URL path to a Python function. When someone visits that path, Flask runs your function and sends back whatever it returns.

Meet the Decorator

You attach a route using @app.route, a decorator written on the line just above your function. It tells Flask which path this function should handle.

@app.route("/")
def home():
    return "Welcome!"

All lessons in this course

  1. The @app.route Decorator
  2. How a Request Becomes a Response
  3. Return Strings, HTML, and Status Codes
  4. Multiple Routes in One App
← Back to Flask Academy