A resource-oriented web services framework
Project description
Bedframe is a resource-oriented web services framework.
Examples
“Hello, world” service
import bedframe as _bedframe
import bedframe.webtypes as _webtypes
class HelloWorldResource(_bedframe.WebResource):
@_bedframe.webmethod(_webtypes.unicode)
def get(self):
return u'Hello, world!'
service = _bedframe.WebService(uris=('http://localhost:8080',))
service.resources[r'/helloworld'] = HelloWorldResource
service.start()
Example usage (Napper):
>>> import bedframe.webtypes as _webtypes
>>> import napper as _napper
>>> uri = 'http://localhost:8080/helloworld'
>>> response = _napper.request_uri('get', uri)
>>> hello = _napper.extract_retval(response, _webtypes.unicode)
>>> print hello
Hello, world!
Example usage (Requests):
>>> import requests as _requests
>>> uri = 'http://localhost:8080/helloworld'
>>> headers = {'Accept': ', '.join(('application/json', '*/*; q=0.01'))}
>>> response = _requests.get(uri, headers=headers)
>>> hello = response.json()['retval']
>>> print hello
Hello, world!
Example usage (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"
}
Changelog
0.13.0 (2013-10-11)
First public version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Bedframe-0.13.3.tar.gz
(101.0 kB
view hashes)
Built Distributions
Bedframe-0.13.3-py27-none-any.whl
(129.3 kB
view hashes)
Bedframe-0.13.3-py2.7.egg
(120.8 kB
view hashes)
Close
Hashes for Bedframe-0.13.3-py27-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 496fa937231799a55b29ea8d7462745904a76f9a04c29e978cac0c2d2018ef99 |
|
MD5 | 2ac96a5ab48a4892a2308c233e881bf2 |
|
BLAKE2b-256 | 1340a00cb23fe991351829114268b3f3bbb2aca38f5d782df8757b6f15d29153 |