Created
October 9, 2013 15:35
-
-
Save mythosil/6903175 to your computer and use it in GitHub Desktop.
start simple http server
serve static files in the current directory
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/sh | |
function http_server() { | |
local PORT=8888 | |
if [ $# -ne 0 ]; then | |
expr $1 + 1 > /dev/null 2>&1 | |
if [ $? -lt 2 ]; then | |
PORT=$1 | |
else | |
echo "Usage: http_server <port>" return 1 | |
fi | |
fi | |
local PYVER=`python -V 2>&1 > /dev/null | cut -d' ' -f2` | |
if expr $PYVER : "2" > /dev/null; then | |
python -m SimpleHTTPServer $PORT | |
elif expr $PYVER : "3" > /dev/null; then | |
python -m http.server $PORT | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment