From 843f80c54aa221c4dc8dce5241bf7218f158bfbc Mon Sep 17 00:00:00 2001 From: w1n5t0n Date: Wed, 4 Mar 2026 20:47:06 +0000 Subject: [PATCH] chore: add playground serve script --- playground/serve.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 playground/serve.sh diff --git a/playground/serve.sh b/playground/serve.sh new file mode 100755 index 0000000..320d623 --- /dev/null +++ b/playground/serve.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Serve the NISPS playground, finding an open port if needed. + +PORT="${1:-8000}" +MAX_ATTEMPTS=20 +DIR="$(cd "$(dirname "$0")" && pwd)" + +for ((i = 0; i < MAX_ATTEMPTS; i++)); do + candidate=$((PORT + i)) + if ! ss -tlnp 2>/dev/null | grep -q ":${candidate} "; then + echo "Serving playground at http://localhost:${candidate}" + exec python3 -m http.server "$candidate" -d "$DIR" + fi + echo "Port ${candidate} in use, trying next..." +done + +echo "No open port found in range ${PORT}–$((PORT + MAX_ATTEMPTS - 1))" >&2 +exit 1