skip to navigation
skip to content

Flask-Holster 0.2.4

Rigid MVC content negotiation for Flask

Latest Version: 0.3.4

This is Holster, an extension for Flask that makes RESTfulness and content negotiation easy:

from flask import Flask
from flask.ext.holster.main import init_holster

app = Flask(__name__)

def test():
    from math import pi

    return {
        "data": "Hello from Holster!",
        "nested": {
            "numeric": 0,
            "floating": pi,
            "unicode": u"Espa\xf1ol",
        "secure": {
            "xss-sword": ';!--"<XSS>=&{()}',

if __name__ == "__main__":

This application will automatically figure out which data type to return, using a combination of user agent parameters and URL extensions. If a user agent requests “/test.html” they will get HTML, but if they request “/test.json” they will get JSON instead. No longer do you have to worry about constructing sites with separate interfaces for HTML and JSON; one holstered site can do it all!

Holster currently has default renderers for the following formats:

  • HTML
  • JSON
  • Plaintext
  • YAML

Users can also override renderers for any format or MIME type they would like, with with_template:

from my_sweet_website import PNGHeaderMaker
from flask.ext.holster.views import with_template

@with_template("image/png", PNGHeaderMaker)
def custom():
    return {"header": "Welcome to my site!"}



  • Bugfix: Correctly omit trailing colons (and related recursion) on list items in the default HTML view template.


  • Bugfix: Permit kwargs in routing decorators, including methods.
  • Bugfix: Pass along premade responses as-is without any interference. Permits things like redirect() inside otherwise-rigid controllers.


  • Bugfix: Pass along names inside lift() to correctly name reversed routes


  • Bugfix: Specialize extended routes for “/” to avoid malformed routes


  • Compatibility: Don’t use itertools, for Python 2.5
  • Enhancement: Split holsterizing views into two pieces, for easier customization
  • Feature: New helpers module for helping write customized views


  • Feature: Changelog
  • Feature: Documentation
  • Feature: Optional HOLSTER_COMPRESS setting for automatically compressing response data
  • Enhancement: Vary header is filled out
  • Change: Improved names of view objects
File Type Py Version Uploaded on Size
Flask-Holster-0.2.4.tar.gz (md5) Source 2013-06-07 6KB