How Can I Get The View Function From An Endpoint/rule?
In Flask(or werkzeug), how can I get the view function when all I have is the Rule? (or the Endpoint from that rule)?
Solution 1:
Werkzeug only stores a map of rules, each of which has an endpoint. Flask adds to Werkzeug by associating each endpoint with a function. Use the app.view_functions
dict to get the view function from the endpoint name.
# assuming r is a Rule
f = app.view_functions[r.endpoint]
Post a Comment for "How Can I Get The View Function From An Endpoint/rule?"