Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from werkzeug.wrappers import Request, Response
- from werkzeug.serving import run_simple
- from jsonrpc import JSONRPCResponseManager, dispatcher
- @dispatcher.add_method
- def foobar(uno, due):
- return uno + due
- @dispatcher.add_method
- def sum_all(*args):
- return sum(args)
- @Request.application
- def application(request):
- # Dispatcher is dictionary {<method_name>: callable}
- dispatcher["echo"] = lambda s: s
- dispatcher["add"] = lambda a, b: a + b
- response = JSONRPCResponseManager.handle(
- request.data, dispatcher)
- return Response(response.json, mimetype='application/json')
- if __name__ == '__main__':
- run_simple('localhost', 4000, application)
Advertisement
Add Comment
Please, Sign In to add comment