Skip to content

Instantly share code, notes, and snippets.

@jrnickell
Last active February 13, 2019 00:36
Show Gist options
  • Save jrnickell/bd57577a22ea5534ad79 to your computer and use it in GitHub Desktop.
Save jrnickell/bd57577a22ea5534ad79 to your computer and use it in GitHub Desktop.
Docker Python HTTP Server
#!/usr/bin/env bash
# place in ~/bin or a PATH directory
#
# usage:
#
# $ cd /path/to/site
# $ serve-static 8443
#
# port number defaults to 8000
if [[ -z $1 ]]; then
SERVE_PORT="8000"
else
SERVE_PORT="$1"
fi
docker run -v $(pwd):$(pwd) -w $(pwd) -p 0.0.0.0:$SERVE_PORT:$SERVE_PORT -it --rm --name="python-http-server" python:2.7 python -m SimpleHTTPServer $SERVE_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment