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
| Name | Type | Description |
|---|---|---|
| addr | string | The IP address or hostname the server should bind to. |
| port | integer | The network port number on which the server listens for incoming connections. |
| wsgi_handler | callable | The WSGI application callable that will process incoming HTTP requests. |
| ipv6 | boolean = False | Whether to use IPv6 addressing instead of the default IPv4. |
| threading | boolean = False | Enables multi-threaded request handling and sets daemon threads for faster shutdown during restarts. |
| on_bind | callable = None | An optional callback function executed after the server binds to the port, receiving the actual server port as an argument. |
| server_cls | class = WSGIServer | The server class to instantiate, allowing for custom server implementations. |
Returns
| Type | Description |
|---|---|
null | This function runs an infinite loop and does not return unless the server is stopped. |