Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blueshed/blueshed-gust
https://github.com/blueshed/blueshed-gust
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/blueshed/blueshed-gust
- Owner: blueshed
- Created: 2024-05-07T09:28:52.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-06-24T22:16:38.000Z (7 months ago)
- Last Synced: 2024-12-01T15:17:35.662Z (about 2 months ago)
- Language: Python
- Size: 352 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - blueshed/blueshed-gust - (Python)
README
# Gust
![PyPI - Version](https://img.shields.io/pypi/v/blueshed-gust?pypiBaseUrl=https%3A%2F%2Fpypi.org&style=social)
Gust is a wrapper of [tornado](https://www.tornadoweb.org/en/stable/). It allows for a hello world such as:
```python
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:
```python
@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:
```javascript
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.