面向资源的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)
- 第一个公开版本。