INNER CODE UNIT · Python
WebServer
dusty-nv/jetson-containers · packages/llm/local_llm/web/server.py:21
class WebServer():
"""
HTTP/HTTPS Flask webserver with websocket messaging.
Use this by either creating an instance and providing msg_callback,
or inherit from it and implement on_message() in a subclass.
You can also add Flask routes to Webserver.app before start() is called.
TODO: multi-client?
remove send queue because the connection dropping is messing things up
instead, have one master self.websocket that send_message() calls directly
"""
MESSAGE_JSON = 0 # json websocket message (dict)
MESSAGE_TEXT = 1 # text websocket message (str)
MESSAGE_BINARY = 2 # binary websocket message (bytes)
MESSAGE_FILE = 3 # file upload from client (bytes)
MESSAGE_AUDIO = 4 # audio samples (bytes, int16)