Flask-Holster
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__)
init_holster(app)
@app.holster("/test")
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__":
app.run()
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 (with optional PyYAML support for prettified YAML)
These default renderers are provided mostly for bootstrapping and development, although the JSON and YAML renderers are likely very similar to the renderers that one might desire in production.
Changelog
0.3.4
Feature: The JSON renderer can render custom objects if they implement a __json__ method for reducing to JSON-safe objects.
0.3.3
Bugfix: Multiple holsterings of a single view in Flask 0.10 and newer were causing Flask to refuse to register views due to an internal assertion being triggered.
Feature: The "title" key now holds special significance: it will be used for titles in built-in renderers, if the renderer supports the notion of a title.
0.3.2
Bugfix: Custom templaters were being incorrectly unused if they were not HTML or JSON templaters.
Feature: Allow “svg” as an extension for the “image/svg+xml” MIME type.
0.3.1
Bugfix: Remove extraneous debugging statements.
0.3
Compatibility: Require vcversioner for version numbers.
Compatibility: The handwritten MIME parser has been removed in favor of the one in Werkzeug. As a result, Flask-Holster is slightly smaller and should handle corner cases slightly better.
Bugfix: Always define a YAML conversion. For pretty YAML, install PyYAML. YAML output is now always enabled, using JSON as a fallback when PyYAML is not available. PyYAML is not required and is not in the requirements.txt.
0.2.5
Feature: init_holster() now works on Flask blueprints as well as Flask applications.
0.2.4
Bugfix: Correctly omit trailing colons (and related recursion) on list items in the default HTML view template.
0.2.3
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.
0.2.2
Bugfix: Pass along names inside lift() to correctly name reversed routes
0.2.1
Bugfix: Specialize extended routes for “/” to avoid malformed routes
0.2
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
1.1.2
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
Metadata
Release files for Flask-Holster 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| Flask-Holster-0.3.4.tar.gz | 7.5 kB | Without provenance | Details |
Release files / Flask-Holster-0.3.4.tar.gz
| Download URL | Flask-Holster-0.3.4.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
acbbf75cce0df474f469ed3af44199d2eb02ef519db0f6dc7e1d1ac80f538565
|
|
BLAKE2b-256 checksum How to use checksums |
1c7f74792c64952bd3a9640a606b8fe12bb8319245d20f29e3a86a61509cbd4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-Holster 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.