Simple response utility for Flask.
Switch branches/tags
Nothing to show
Clone or download
Parkayun Merge pull request #14 from yangroro/master
README.rst: Fix broken pypi version image
Latest commit 631a2c2 Apr 12, 2017
Permalink
Failed to load latest commit information.
flask_responses Fixed auto_response bug Jan 19, 2015
tests fix set header bug Jan 19, 2015
.travis.yml Update .travis.yml Jan 19, 2015
README.rst Fix broken version image Apr 11, 2017
setup.py update setup.py Jan 19, 2015

README.rst

Flask-Responses 0.2

Latest Version Build Status Coverage Status
.. module:: flask.ext.responses

Simple response utility for Flask.

Installation

~ $ python setup.py install

or can use pip

~ $ pip install flask-responses

Quick start

from flask import Flask
from flask.ext.responses import json_response, xml_response, auto_response

app = Flask(__name__)

@app.route("/json")
def hello():
    return json_response({"message": "Hello World!"}, status_code=201)

@app.route("/xml")
def world():
   # or can do this return xml_response('<message>Hello World</message>')
   return xml_response({"message": "Hello World!"}, headers={'x-foo': 'bar'})

@app.route("/auto")
def auto():
   # auto response json or xml by Accept request header
   return auto_response({"message": "Hello World!"}, status_code=201, headers={'x-foo': 'bar'})

Responses

  • JSON (json_response)
  • XML (xml_response)

ToDo

  • allow origin cross domain
  • server sent events