a library.
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);
};
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.15.tar.gz
(10.1 kB
view hashes)
Built Distribution
Close
Hashes for blueshed_gust-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a897cc06a01eb7f27140ed4eba8ebc498f232d970d49dff01b9628191989fd5 |
|
MD5 | aa63f77ec3d14b98feaf859d61a7e65e |
|
BLAKE2b-256 | 480b3672626f4631323f6ab6d689c6368761d55aaefd424176401762fa894a61 |