~duncan-bayne/setups

8de1a2333eb1f4549199cda724d4d139cfd52baa — Duncan Bayne 9 months ago d9e675b
Add a utility script to serve a directory on the Web
1 files changed, 21 insertions(+), 0 deletions(-)

A mint/conf/bin/,ws
A mint/conf/bin/,ws => mint/conf/bin/,ws +21 -0
@@ 0,0 1,21 @@
#!/usr/bin/env bash

set -euo pipefail
shellcheck "$0"

if [ "$#" -gt 2 ] || [ "${1-}" = "--help" ]
then
    {
	echo "Usage: ,ws [HOST] [PORT]"
	echo
	echo "Serve the current directory as a Web server on PORT and HOST.  PORT "
	echo "defaults to 8080, HOST to 0.0.0.0."
    } 1>&2
    exit 1;
fi

HOST=${1:-0.0.0.0}
PORT=${2:-8080}

python3 -m http.server --bind "$HOST" "$PORT"