quart.wrappers.websocket module

class quart.wrappers.websocket.Buffer

Bases: object

async put(data)
Parameters:

data (bytes | str)

Return type:

None

async get()
Return type:

bytes | str

disconnect()
Return type:

None

class quart.wrappers.websocket.Websocket(path, query_string, scheme, headers, root_path, http_version, subprotocols, send, accept, close, scope)

Bases: BaseRequestWebsocket

This class represents a websocket.

It can be subclassed and the subclassed used in preference by replacing the websocket_class with your subclass.

Parameters:
  • path (str)

  • query_string (bytes)

  • scheme (str)

  • headers (Headers)

  • root_path (str)

  • http_version (str)

  • subprotocols (list[str])

  • send (Callable)

  • accept (Callable)

  • close (Callable)

  • scope (WebsocketScope)

buffer_class

The class to process the incoming messages.

buffer_class

alias of Buffer

property requested_subprotocols: list[str]
async receive()
Return type:

str | bytes

async send(data)
Parameters:

data (str | bytes)

Return type:

None

async receive_json()
Return type:

Any

async send_json(*args, **kwargs)
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

None

async accept(headers=None, subprotocol=None)

Manually chose to accept the websocket connection.

Parameters:
  • headers (dict | Headers | None) – Additional headers to send with the acceptance response.

  • subprotocol (str | None) – The chosen subprotocol, optional.

Return type:

None

async close(code, reason='')
Parameters:
  • code (int)

  • reason (str)

Return type:

None