scripts

My personal collection of scripts
git clone git://src.gearsix.net/scriptsscripts.zip
Log | Files | Refs | Atom | README | LICENSE

pyserve.sh (raw) (518B)


   1 #!/usr/bin/env sh
   2 
   3 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
   4 	echo "usage: ./pyserve.sh [DIRECTORY] [PORT]"
   5 	echo ""
   6 	echo "Shorthand for 'python3 -m http.server --directory DIRECTORY PORT'"
   7 	echo ""
   8 	echo "DIRECTORY    (default: '.') The directory to use as the root directory of the webserver"
   9 	echo "PORT         (default: 8001) The port to use for the webserver"
  10 	exit
  11 fi
  12 
  13 dir="."
  14 port="8001"
  15 
  16 if [ "$1" ]; then dir="$1"; fi
  17 if [ "$2" ]; then port="$2"; fi
  18 
  19 python3 -m http.server --directory "$dir" "$port"