面向资源的web服务框架

Bedframe的Python项目详细描述


bedframe是一个面向资源的web服务框架。

安装

bedframe服务在底层web服务器上运行。支持每个 通过相应的插件提供特定的web服务器。床架 发布包括一些web服务器插件,这些插件由 安装相应的程序包附加程序。这些是目前 支持的附加功能:

^{tt1}$
Support for the Tornado web server (via tornado.web.Application).
^{tt2}$
Support for the Tornado WSGI web server (via tornado.wsgi.WSGIApplication).

例如,要安装支持Tornado WSGi Web的床架 服务器,您可以运行

pip install bedframe[tornado_wsgi]

此外,床架还支持以下附加功能:

^{tt3}$
Support for the Lightweight Directory Access Protocol (LDAP) for authentication (via python-ldap).
^{tt4}$
Support for memcached for authentication (via python-memcached).
^{tt5}$
Support for the Lightweight Directory Access Protocol (LDAP) for automated testing (via Spruce-ldap and OpenLDAP).

示例

“你好,世界”服务

importbedframeas_bedframeimportbedframe.webtypesas_webtypesclassHelloWorldResource(_bedframe.WebResource):@_bedframe.webmethod(_webtypes.unicode)defget(self):returnu'Hello, world!'service=_bedframe.WebService(uris=('http://localhost:8080',))service.resources[r'/helloworld']=HelloWorldResourceservice.start()

示例用法(napper):

>>>importbedframe.webtypesas_webtypes>>>importnapperas_napper>>>uri='http://localhost:8080/helloworld'>>>response=_napper.request_uri('get',uri)>>>hello=_napper.extract_retval(response,_webtypes.unicode)>>>printhelloHello,world!

示例用法(Requests):

>>>importrequestsas_requests>>>uri='http://localhost:8080/helloworld'>>>headers={'Accept':', '.join(('application/json','*/*; q=0.01'))}>>>response=_requests.get(uri,headers=headers)>>>hello=response.json()['retval']>>>printhelloHello,world!

示例用法(HTTPie):

$ uri='http://localhost:8080/helloworld'
$ http get "$uri" Accept:'application/json,*/*; q=0.01' --body
{"auth_info": {"accepted": null,
        "realm": null,
        "user": null
    },
    "retval": "Hello, world!",
    "type": "bedframe._responses._return:WebReturnResponse"}

更改日志

0.13.0(2013-10-11)

  • 第一个公开版本。

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

推荐PyPI第三方库


热门话题
java如何显示因用户而异的SQLite存储数据?   转换java。sql。将映射传递给Jackon的valueToTree方法时StringNode的时间戳   从java中的列表json获取值   unicode Java字符存储在什么编码中?   java如何让Spring数据存储库中的默认方法命中缓存?   java使用readClassDescriptor()和resolveClass()来允许序列化版本控制   数组通过另一个矩阵的一部分填充矩阵   如果包含使用正则表达式的字符串,则替换父XML标记的java   java清除SharedReference中的单个变量   java将变量值从一个jsp页面传输到另一个jsp页面   java JDBC+SQLite:DriveManager不加载所需的驱动程序   相同源代码的java Kotlin构建生成不同的二进制文件   Java中的元组枚举