Labeled Listener Builder#

The ngrok Agent SDK for Python

class ngrok.LabeledListenerBuilder#

A labeled ngrok listener.

app_protocol(app_protocol)#

Set the L7 application protocol used for this listener, i.e. “http1” or “http2” (default “http1”)

label(label, value)#

Add a label, value pair for this listener. See Using Labels in the ngrok docs for additional details.

listen()#

Begin listening for new connections on this listener.

listen_and_forward(to_url)#

Begin listening for new connections on this listener and forwarding them to the given url. This url can be either a TCP/HTTP address or a file socket path, for example: “http://localhost:8080”, “https://192.168.1.100:8443”, or for file socket paths on Linux/Darwin “unix:///path/to/unix.sock”.

Parameters:

to_url – The URL to forward traffic on to

Returns:

A task to await for the Listener linked with the server.

Return type:

Task

listen_and_serve(server)#

Begin listening for new connections on this listener and forwarding them to the given http server.

Parameters:

server (http.server.HTTPServer or None) – The server to link with a Listener.

Returns:

A task to await for the Listener linked with the server.

Return type:

Task

metadata(metadata)#

Listener-specific opaque metadata. Viewable via the API.

verify_upstream_tls(verify_upstream_tls)#

Whether to disable certificate verification for this listener.