lite additions to tornado.
Project description
Gust
Gust is a wrapper of tornado. It allows for a hello world such as:
from blueshed.gust import Gust, web
@web.get('/(.*)')
def get(request):
"""just a get"""
return 'hello, world'
def main():
"""seperate construction from run"""
Gust().run()
if __name__ == '__main__':
main()
Similarly, you can write:
@web.ws_json_rpc('/websocket')
def add(a:float, b:float) -> float:
"""simple addition"""
return a + b
And use a javascript websocket client to call the function:
const ws = new WebSocket("ws://localhost:8080/websocket");
ws.onopen = function () {
ws.send(
JSON.stringigy({
jsonrpc: "2.0",
id: 1,
method: "add",
params: { a: 2.0, b: 2.0 }, // or [2.0, 2.0]
}),
);
};
ws.onmessage = function (evt) {
const pre = document.createElement("pre");
pre.textContent = evt.data;
document.body.appendChild(pre);
};
There are simple sample apps in src/tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
blueshed_gust-0.0.19.tar.gz
(10.1 kB
view hashes)
Built Distribution
Close
Hashes for blueshed_gust-0.0.19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beb5981c141d6e42dd1043b0fd4d0f8e500129bd7f07b3b1be02705b7bc77566 |
|
MD5 | a4ba5c19cd9812c11f73d4cc470d18f3 |
|
BLAKE2b-256 | 7e319606c8ee39ffad4b5ff93da3e20d486f79bfff4b992524c4ad4d8f7529a7 |