What does the url_for() function do in Flask?

What does the url_for() function do in Flask?

a) It generates a URL for the specified function or endpoint
b) It redirects the user to a new page
c) It renders an HTML template
d) It manages HTTP methods

Answer:

a) It generates a URL for the specified function or endpoint

Explanation:

The url_for() function in Flask is used to dynamically generate a URL for the specified function or view by passing the function name.

Reference:

Flask Quiz – MCQ Questions and Answers

Scroll to Top