#!/bin/sh -eu
#
# server - start an HTTP server from dir, optionally specify port (default: 8000)
# usage: server [port]

port="${1:-8000}"
myip=$(ifconfig | grep "inet " | grep -v '127.*' | awk '{ print $2 }')
echo "Access from the network: http://${myip}:${port}"
echo
open "http://localhost:${port}/"
# ARGS="$@"
# python3 -m http.server "${ARGS}" 2>/dev/null &
python3 -m http.server --bind 0 --directory . "${port}" 2>/dev/null &
