Skip to content

App

launch_in_jupyter(host='127.0.0.1', port=7637, threads=10)

Launch the HTTP API server in Python environment.

Parameters:

Name Type Description Default
host str

The host to bind to. Default is '127.0.0.1'

'127.0.0.1'
port int

The port to bind to. Default is 7637.

7637
threads int

Number of threads per worker. Default is 10.

10

Returns:

Type Description

None

Source code in lynse/api/http_api/http_api/app.py
def launch_in_jupyter(host: str = '127.0.0.1', port: int = 7637, threads: int = 10):
    """
    Launch the HTTP API server in Python environment.

    Parameters:
        host (str): The host to bind to. Default is '127.0.0.1'
        port (int): The port to bind to. Default is 7637.
        threads (int): Number of threads per worker. Default is 10.

    Returns:
        None
    """
    import threading
    if host == '0.0.0.0':
        local_ip = get_local_ip()
        print(f"Server running at:")
        print(f"  - Localhost: http://localhost:{port}")
        print(f"  - Local IP: http://{local_ip}:{port}", end="\n\n")
    else:
        print(f"Server running at http://{host}:{port}", end="\n\n")

    # set the thread as daemon thread
    server_thread = threading.Thread(target=serve, args=(app,), kwargs={'host': host, 'port': port, 'threads': threads})
    server_thread.daemon = True
    server_thread.start()