zaku.base
Server Base Class

async zaku.base.default_handler(request, ws)[source]
async zaku.base.websocket_handler(request, handler, **ws_kwargs)[source]
async zaku.base.handle_file_request(request, root, filename=None)[source]
class zaku.base.Server[source]

Base TCP server

host: str = 'localhost'
port: int = 8012
cors: str = '*'

Enable CORS

cert: str = None

the path to the SSL certificate

key: str = None

the path to the SSL key

ca_cert: str = None

the trusted root CA certificates

WEBSOCKET_MAX_SIZE = 268435456
REQUEST_MAX_SIZE = 268435456
__post_init__()[source]
_route(path: str, handler: callable, method: str = 'GET')[source]
Parameters:
  • path (str) –

  • handler (callable) –

  • method (str) –

_socket(path: str, handler: callable)[source]
Parameters:
  • path (str) –

  • handler (callable) –

static _add_task(fn: Coroutine, name=None)[source]
Parameters:

fn (Coroutine) –

__annotations__ = {'ca_cert': <class 'str'>, 'cert': <class 'str'>, 'cors': <class 'str'>, 'host': <class 'str'>, 'key': <class 'str'>, 'port': <class 'int'>}
_static(path, root)[source]
_static_file(path, root, filename=None)[source]
run()[source]

Simple Runner

When using gunicorn, this gets replace by the gunicorn runner. gunicorn is responsible for handling the ssl certification, and the port binding.

`shell $ gunicorn --certfile=server.crt --keyfile=server.key --bind 0.0.0.0:443 test:app `