python-websocketd
Python module for creating a http server which uses WebSockets.

◆ reply()

def websocketd.Httpd.reply (   self,
  connection,
  code,
  message = None,
  content_type = None,
  headers = None,
  close = False 
)

Reply to a request for a document.

There are three ways to call this function:

  • With a message and content_type. This will serve the data as a normal page.
  • With a code that is not 101, and no message or content_type. This will send an error.
  • With a code that is 101, and no message or content_type. This will open a websocket.
    Parameters
    connectionRequesting connection.
    codeHTTP response code to send. Use 200 for a valid page.
    messageData to send (as bytes), or None for an error message just showing the response code and its meaning.
    content_typeContent-Type of the message, or None if message is None.
    headersHeaders to send in addition to Content-Type and Content-Length, or None for no extra headers.
    closeTrue if the connection should be closed after this reply.
    Returns
    None.

Definition at line 1201 of file websocketd.py.

Here is the caller graph for this function: