class documentation

class MethodView(View):

View In Hierarchy

A class-based view that dispatches request methods to the corresponding class methods. For example, if you implement a get method, it will be used to handle GET requests.

class CounterAPI(MethodView):
    def get(self):
        return session.get('counter', 0)

    def post(self):
        session['counter'] = session.get('counter', 0) + 1
        return 'OK'

app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
Method dispatch​_request Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.

Inherited from View:

Class Method as​_view No summary
Class Variable decorators Undocumented
Class Variable methods Undocumented
Class Variable provide​_automatic​_options Undocumented
def dispatch_request(self, *args, **kwargs):
Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.
Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
ResponseReturnValueUndocumented