Color.Palette.Visualizer.Standalone (Color v0.11.0)

Copy Markdown

A tiny helper that runs Color.Palette.Visualizer as a standalone web server for local development.

Requires :bandit in your project's deps.

Color.Palette.Visualizer.Standalone.start(port: 4001)
# Visit http://localhost:4001

To stop the server, call Color.Palette.Visualizer.Standalone.stop/1 with the PID returned from start/1.

Summary

Functions

Returns a child spec suitable for embedding under a supervision tree.

Starts the visualizer on the given port.

Stops a standalone server started by start/1.

Functions

child_spec(options \\ [])

@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a child spec suitable for embedding under a supervision tree.

Options

See start/1.

Returns

  • A child specification map.

start(options \\ [])

@spec start(keyword()) :: {:ok, pid()} | {:error, term()}

Starts the visualizer on the given port.

Options

  • :port — TCP port to listen on. Default 4001.

  • :ip — IP address to bind to. Default :loopback (only accessible from localhost). Pass :any to bind on all interfaces.

Returns

  • {:ok, pid} on success.

  • {:error, reason} on failure — most commonly a port-in-use error.

stop(pid)

@spec stop(pid()) :: :ok

Stops a standalone server started by start/1.

Arguments

  • pid — the process identifier returned by start/1.

Returns

  • :ok.