Module areixio.utils.simple_webserver

Functions

def SignalServer(identifier: str, callback: Callable)

Spawns an http.server.HTTPServer in a separate thread on the given port. The hostname is always "localhost". Parameters


identifier : str, optional
The identifier …
callback : Callable, optional
The callback function …

Returns

http.server.HTTPServer
The HTTP server which is serving files from a separate thread. It is not super necessary but you might want to call shutdown() on the returned HTTP server object. This will stop the inifinite request loop running in the thread which in turn will then exit. The reason why this is only optional is that the thread in which the server runs is a daemon thread which will be terminated when the main thread ends. By calling shutdown() you'll get a cleaner shutdown because the socket is properly closed.
str
The address of the server as a string, e.g. "http://localhost:1234".

Ref

https://gist.github.com/kwk/5387c0e8d629d09f93665169879ccb86 https://docs.aws.amazon.com/zh_tw/polly/latest/dg/example-Python-server-code.html

Classes

class ResponseStatus (code, message)

HTTPStatus(code, message)

Ancestors

  • builtins.tuple

Instance variables

var code

Alias for field number 0

var message

Alias for field number 1

class HTTPStatusError (status, description=None)

Exception wrapping a value from http.server.HTTPStatus

Constructs an error instance from a tuple of (code, message, description), see http.server.HTTPStatus

Ancestors

  • builtins.Exception
  • builtins.BaseException
class ResponseData (status, content_type, data_stream)

ResponseData(status, content_type, data_stream)

Ancestors

  • builtins.tuple

Instance variables

var content_type

Alias for field number 1

var data_stream

Alias for field number 2

var status

Alias for field number 0