class documentation

class MethodView(View): (source)

View In Hierarchy

Dispatches request methods to the corresponding instance methods. For example, if you implement a ``get`` method, it will be used to handle ``GET`` requests. This can be useful for defining a REST API. :attr:`methods` is automatically set based on the methods defined on the class. See :doc:`views` for a detailed guide. .. code-block:: python class CounterAPI(MethodView): def get(self): return str(session.get("counter", 0)) def post(self): session["counter"] = session.get("counter", 0) + 1 return redirect(url_for("counter")) app.add_url_rule( "/counter", view_func=CounterAPI.as_view("counter") )

Method __init_subclass__ Undocumented
Method dispatch_request The actual view function behavior. Subclasses must override this and return a valid response. Any variables from the URL rule are passed as keyword arguments.

Inherited from View:

Class Method as_view Convert the class into a view function that can be registered for a route.
Class Variable decorators Undocumented
Class Variable init_every_request Undocumented
Class Variable methods Undocumented
Class Variable provide_automatic_options Undocumented
def __init_subclass__(cls, **kwargs: t.Any): (source)

Undocumented

def dispatch_request(self, **kwargs: t.Any) -> ft.ResponseReturnValue: (source)

The actual view function behavior. Subclasses must override this and return a valid response. Any variables from the URL rule are passed as keyword arguments.