In Flask, which decorator is used to bind a function to a URL?

In Flask, which decorator is used to bind a function to a URL?

a) @app.route()
b) @flask.url()
c) @route()
d) @url_for()

Answer:

a) @app.route()

Explanation:

The @app.route() decorator in Flask binds a URL to a specific function, defining how that URL is handled by the application.

Reference:

Flask Quiz – MCQ Questions and Answers

Scroll to Top