Skip to content

Instantly share code, notes, and snippets.

@zenoamaro
Last active August 29, 2015 14:22
Show Gist options
  • Save zenoamaro/0c294aa359cc61c3bda0 to your computer and use it in GitHub Desktop.
Save zenoamaro/0c294aa359cc61c3bda0 to your computer and use it in GitHub Desktop.
Small scripts for common network tasks.
#!/bin/bash
set -e
if [[ "$1" == '-h' ]]; then
echo 'Starts a simple HTTP server publishing the current directory.'
echo "Usage: $(basename $0) [directory=pwd] [port=8080]"
exit 0
fi
if [[ -z $(command -v python) ]]; then
echo 'This script requires Python.'
exit 1
fi
if [[ -n "$1" ]]; then
WD="$1"
else
WD="$PWD"
fi
if [[ -n "$2" ]]; then
PORT="$2"
else
PORT='8080'
fi
if [[ ! -d "$WD" ]]; then
echo "Cannot find directory \`$WD\`."
exit 2
fi
cd "$WD"
python -m SimpleHTTPServer $PORT
- Miniserver
Starts a simple HTTP server publishing the current directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment