File: sanic_server.py

package info (click to toggle)
python-ajsonrpc 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 524 kB
  • sloc: python: 1,286; makefile: 56; sh: 17
file content (13 lines) | stat: -rw-r--r-- 299 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
from sanic import Sanic
from ajsonrpc.backend.sanic import JSONRPCSanic

app = Sanic("Example App")
api = JSONRPCSanic()
app.route("/jsonrpc", methods=["POST",])(api.handler)

@api.add_function
async def add(a, b):
    return a + b

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)