flask_velox.mixins.http

Module provides mixins for issuing HTTP Status codes using the Flask View.

class flask_velox.mixins.http.RedirectMixin

Bases: flask.views.View

Raise a HTTP Redirect, by default a 302 HTTP Status Code will be used however this can be overridden using the code attribute.

Example

1
2
3
4
from flask.ext.velox.mixins.http import RedirectMixin
class MyView(RedirectMixin):
    rule = 'some.url.rule'
    code = 301
rule str

Flask URL Rule passed into url_for

code int, optional

Status code to raise, defaults to 302

dispatch_request(*args, **kwargs)

Dispatch the request, returning the redirect.func_closure

Returns:Redirect response
Return type:werkzeug.wrappers.Response
get_url()

Return a generated url from rule attribute.

Returns:Generated url
Return type:str
pre_dispatch(*args, **kwargs)

If you wish to run an arbitrary piece of code before the redirect is dispatched you can override this method which is called before dispatch.

http://thisissoon.com

Related Topics

This Page