烧瓶的刚性MVC含量协商

Flask-Holster的Python项目详细描述


这是皮套,是烧瓶的延伸,它能使人平静和满足。 谈判容易:

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()

此应用程序将自动确定要返回的数据类型, 使用用户代理参数和url扩展名的组合。如果用户 代理请求“/test.html”它们将获得html,但是如果它们请求 “/test.json”它们将得到json。你不用再担心了 为html和json构建单独接口的站点;一个 网站可以做到这一切!

枪套目前有以下格式的默认渲染器:

  • HTML
  • JSON
  • Plaintext
  • YAML (with optional PyYAML support for prettified YAML)

这些默认呈现器主要用于引导和开发, 尽管json和yaml呈现器可能与呈现器非常相似 一个人在生产中可能想要的。

更改日志

0.3.4

  • Feature: The JSON renderer can render custom objects if they implement a ^{tt1}$ 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 ^{tt2}$ 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: ^{tt3}$ 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 ^{tt4}$.
  • Bugfix: Pass along premade responses as-is without any interference. Permits things like ^{tt5}$ inside otherwise-rigid controllers.

0.2.2

  • Bugfix: Pass along names inside ^{tt6}$ 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 ^{tt7}$ setting for automatically compressing response data
  • Enhancement: Vary header is filled out
  • Change: Improved names of view objects

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
为什么Java中有三种“阻塞”线程状态,而C中只有一种?   JAVA从文本文件中找到几个单词或短语并显示出来   java更改日志。Jenkins中的xml文件,无需重新生成代码   java使用扫描器读取“干净”文本文件时,是否有任何解析?   stream从InputStream中获取字节数组,但在Java中没有已知大小?   java一旦布尔值为真,如何关闭JFrame?   java对HashMap中容量计算算法的理解   java 安卓句柄选择器状态   Java Swing编程面板标题   java我希望在启动或启动安卓 mobile时显示消息或通知。   java在一个应用程序中支持多个JFrame   java如何使用SeleniumWebDriver选择网页上的两个元素之一?   java Tomcat部署问题   java意图传递数据未成功   安卓在java中将映射定义为常量   java最佳实践Swing、数据库访问   java com。反恐委员会。wstx。exc.WstxIOException:尝试在封闭流上读取   if语句如何检查java中是否存在表达式中的下一个或最后一个值