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
- The @app.route Decorator
- How a Request Becomes a Response
- Return Strings, HTML, and Status Codes
- Multiple Routes in One App