Metadata-Version: 2.1
Name: blueshed-gust
Version: 0.0.21
Summary: lite additions to tornado.
Author-email: Peter Bunyan <pete@blueshed.co.uk>
License: BSD-3-Clause
Project-URL: Homepage, https://github.com/blueshed/blueshed-gust
Project-URL: Documentation, https://blueshed.github.io/blueshed-gust/blueshed/gust.html
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: python-dotenv
Requires-Dist: tornado
Provides-Extra: dev
Requires-Dist: invoke; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-coverage; extra == "dev"
Requires-Dist: pytest-tornado; extra == "dev"
Requires-Dist: pytest-tornasync; extra == "dev"
Requires-Dist: bump-my-version; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: build; extra == "dev"

<div style="float: right;">
<img src="https://s3.eu-west-1.amazonaws.com/blueshed.info/published/gust3.webp" width="64" title="windy weather">
</div>

# 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.
