跳转到主要内容

Flask的简单响应工具

项目描述

Flask-Responses 0.2
===================

.. image:: https://pypip.in/version/flask-responses/badge.svg
:target: https://pypi.python.org/pypi/flask-responses/
:alt: 最新版本

.. image:: https://secure.travis-ci.org/Parkayun/flask-responses.svg?branch=master
:alt: 构建状态
:target: https://travis-ci.org/Parkayun/flask-responses

.. image:: https://img.shields.io/coveralls/Parkayun/flask-responses.svg
:alt: 覆盖率状态
:target: https://coveralls.io/r/Parkayun/flask-responses

.. module:: flask.ext.responses

Flask的简单响应工具。

.. _Flask: https://flask.org.cn/

安装
-------------

.. sourcecode:: bash

~ $ python setup.py install

或者可以使用pip

.. sourcecode:: bash

~ $ pip install flask-responses

快速入门
-----------

.. sourcecode:: python

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()
return xml_response({"message": "Hello World!"}, headers={'x-foo': 'bar'}) # 或者可以这样做 xml_response('<message>Hello World</message>')

@app.route("/auto")
def auto()
return auto_response({"message": "Hello World!"}, status_code=201, headers={'x-foo': 'bar'})

响应
---------
* JSON (json_response)
* XML (xml_response)

待办事项
----
* 允许跨域源
* 服务器发送事件

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源分发

Flask-Responses-0.2.tar.gz (2.6 kB 查看哈希值)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面