View which will dispatch requests based on request method.
This class inherits from:
For example, a GET request will be dispatched to the get method, a POST request will be dispatched to the post method. Example usage:
class MethodView(View):
def get(self, *args, **kwargs):
return 'Hello {0}'.format(self.kwargs.get('user'))
When you have a URL route '/<user>/' and you GET /john/, it will return 'Hello john'.
Dispatch the request based on HTTP method.
This sets the arguments and keyword-arguments passed by the URL route dispatcher to self.args and self.kwargs, then it will dispatch the request to the right method.
View class for rendering templates.
This class inherits from:
Example usage:
class IndexTemplateView(TemplateView):
template_name = 'index.html'
Render the template on request.
The keyword-arguments passed by the URL dispatcher are added to the context data.
Returns: | Output of TemplateResponseMixin.render_to_response(). |
---|
Get context data for rendering the template.
Returns: | A dict containing the following keys:
|
---|
Mixin class for rendering templates.
This will use the flask.render_template() method for rendering (Jinja2) templates.
See also
Render template with the given context data.
Parameters: | context_data – A dict containing the context data. Optional. |
---|---|
Returns: | The rendered template as a string. |
Set this variable to the template you want to render.