1. Peter Fačka
  2. jsonwsp

Overview

HTTPS SSH

JSONWSP

A minimalistic implementation of JSON-WSP protocol

Sever Example

from wsgiref.simple_server import make_server
from jsonwsp import application
from jsonwsp import Service

service = Service('Calculator','/calculator')

@service.params(float, float)
@service.rtype(float)
def mul(left, right):
    """muliply two numbers supplied by parameters"""
    return left*right

@service.params(left=float, right=float)
@service.rtype(float)
def div(**kw):
    left = kw.get('left')
    right = kw.get('right')
    """division of two numbers supplied by parameters"""
    return left/right

httpd = make_server('0.0.0.0', 8051, application)
httpd.serve_forever()

Client Example

connection = ServiceConnection('localhost', 8051, '/calculator')
connection.initialize()

div = connection.get_method('div')
r = div(left=16, right=4)

TODO

  • better test coverage
  • multipart file upload requests
  • Support for JSON-WSP types