Skip to main content

A Flask extension adding a decorator for JSONP support

Project description

Flask-Jsonpify is an extension to Flask’s core jsonify function, returning JSON-Padded responses when a callback is specified as request’s arguments. It’s usage and implementation is the same as flask.jsonify, differing only when a request has a callback specified in the request arguments, in which case the response body is JSON-Padded, or JSONP, using the callback.

To add JSONP support to all routes which previously used flask.jsonify, simply import jsonify from flask.ext.jsonpify instead of importing it from flask. The arguments and responses are fully compatible. Alternatively, import jsonpify from flask.ext.jsonpify to support JSONP in certain places.

Installation

Install the extension with one of the following commands:

$ easy_install flask-jsonpify

or alternatively if you have pip installed (which you should):

$ pip install flask-jsonpify

Usage

The best way to use Flask-Jsonpify is to completely replace Flask’s jsonify with this module’s jsonify function, as shown below. The method is fully compatible.

from flask import Flask
from flask.ext.jsonpify import jsonify

app = Flask(__name__)

@app.route("/")
def index():
    return jsonify(user="lala")


if __name__ == "__main__":
    app.run(debug=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-Jsonpify-1.5.0.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file Flask-Jsonpify-1.5.0.tar.gz.

File metadata

File hashes

Hashes for Flask-Jsonpify-1.5.0.tar.gz
Algorithm Hash digest
SHA256 8ac4c732aa5b11d9f6c2de58065d3b669f139518ca8f529bce943817e2fedbfb
MD5 8a10e37942c43d93d107644a3fe77d98
BLAKE2b-256 600fc389dea3988bffbe32c1a667989914b1cc0bce31b338c8da844d5e42b503

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page