Skip to main content

run

Starts a WSGI server on a specified address and port, optionally enabling threading and IPv6 support, and begins serving the provided WSGI application indefinitely.

def run(
addr: string,
port: integer,
wsgi_handler: callable,
ipv6: boolean = False,
threading: boolean = False,
on_bind: callable = None,
server_cls: class = WSGIServer
) - > null

Starts a WSGI server to handle incoming HTTP requests and serves the provided application indefinitely. This function configures the server instance, binds it to the specified address and port, and optionally enables multi-threading for concurrent request handling.

Parameters

NameTypeDescription
addrstringThe IP address or hostname the server should bind to.
portintegerThe network port number on which the server listens for incoming connections.
wsgi_handlercallableThe WSGI application callable that will process incoming HTTP requests.
ipv6boolean = FalseWhether to use IPv6 addressing instead of the default IPv4.
threadingboolean = FalseEnables multi-threaded request handling and sets daemon threads for faster shutdown during restarts.
on_bindcallable = NoneAn optional callback function executed after the server binds to the port, receiving the actual server port as an argument.
server_clsclass = WSGIServerThe server class to instantiate, allowing for custom server implementations.

Returns

TypeDescription
nullThis function runs an infinite loop and does not return unless the server is stopped.