Skip to main content

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


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)

Uploaded Source

Built Distributions

Bedframe-0.13.3-py27-none-any.whl (129.3 kB view hashes)

Uploaded Python 2.7

Bedframe-0.13.3-py2.7.egg (120.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page