What is the "endpoint" in flask's .add_url_rule()?

Viewed 16066

Consider the following code

import flask

class API:
    def hello(self):
        return flask.Response('hello', 200)

api = API()
app = flask.Flask(__name__)
app.add_url_rule('/', 'hello', api.hello)
app.run()

It returns "hello" upon a GET call to /.

The documentation for add_url_rule states that

[add_url_rule] works exactly like the route() decorator.

It requires however at least three parameters. The first and third one are understandable and mimic @route(). What is the second one (hello in my case)?

The documentation further states that this is

endpoint – the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint

What does this mean? Why isn't the URL (/) and the method to call (api.hello) sufficient? What is the role of the "endpoint"? How is it exactly used?

1 Answers
Related