Shortcuts

Frontend

class lightning_app.frontend.frontend.Frontend[source]

Bases: abc.ABC

Base class for any frontend that gets exposed by LightningFlows.

The flow attribute will be set by the app while bootstrapping.

abstract start_server(host, port)[source]

Start the process that serves the UI at the given hostname and port number.

Parameters
  • host (str) – The hostname where the UI will be served. This gets determined by the dispatcher (e.g., cloud), but defaults to localhost when running locally.

  • port (int) – The port number where the UI will be served. This gets determined by the dispatcher, which by default chooses any free port when running locally.

Example

An custom implementation could look like this:

def start_server(self, host, port):
    self._process = subprocess.Popen(["flask", "run" "--host", host, "--port", str(port)])
Return type

None

abstract stop_server()[source]

Stop the process that was started with start_server() so the App can shut down.

This method gets called when the LightningApp terminates.

Example

def stop_server(self):
    self._process.kill()
Return type

None