Coder Social home page Coder Social logo

flask-responses's Introduction

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

flask-responses's People

Contributors

geonu avatar leejaedus avatar msabramo avatar parkayun avatar yangroro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flask-responses's Issues

charset

Content-type: application/json;charset=UTF-8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.