JSON RPC protocol for aiohttp.web (http server for asyncio)
Project description
aiohttp_jrpc
jsonrpc protocol implementation for aiohttp.web.
Example
import asyncio
from aiohttp import web
from aiohttp_jrpc import Service
SCH = {
"type": "object",
"properties": {
"data": {"type": "string"},
},
}
class MyJRPC(Service):
@Service.valid(SCH)
def hello(self, ctx, data):
if data["data"] == "hello":
return {"status": "hi"}
return {"status": data}
@asyncio.coroutine
def init(loop):
app = web.Application(loop=loop)
app.router.add_route('POST', "/api", MyJRPC)
srv = yield from loop.create_server(app.make_handler(),
"127.0.0.1", 8080)
print("Server started at http://127.0.0.1:8080")
return srv
loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
try:
loop.run_forever()
except KeyboardInterrupt:
pass
License
aiohttp_jrpc BSD license.
CHANGES
0.0.1 (2015-10-18)
Init release
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
aiohttp_jrpc-0.0.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for aiohttp_jrpc-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03b7cc542402d15cbb3785b52d739b30e05d48b4c962078c8c08422e830dfc4a |
|
MD5 | 44a041e24fa1934b6302616482624912 |
|
BLAKE2b-256 | b6ccedaac78a939ad5c0c4245b4a64e26899c8039a35cbb1bb4d40291b522994 |