Last active
August 29, 2015 14:22
-
-
Save zenoamaro/0c294aa359cc61c3bda0 to your computer and use it in GitHub Desktop.
Small scripts for common network tasks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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