Skip to content

Instantly share code, notes, and snippets.

@kabachook
Last active January 8, 2018 21:00
Show Gist options
  • Save kabachook/c9331b32fa15d402f4f5a56f1df1e66e to your computer and use it in GitHub Desktop.
Save kabachook/c9331b32fa15d402f4f5a56f1df1e66e to your computer and use it in GitHub Desktop.
Docker Python3 HTTP server
#!/usr/bin/env bash
# put in PATH directory
# usage:
#
# $ cd path/to/root
# $ serve-static $PORT
#
# port defaults to 8000
if [[ -z $1 ]]; then
SERVE_PORT="8000"
else
SERVE_PORT="$1"
fi
docker run -d --name w1 -v $(pwd):/root -w /root -p $SERVE_PORT:$SERVE_PORT python:alpine python -m http.server $SERVE_PORT
#!/bin/bash
server() {
if [[ -z $@ ]]; then
SERVE_PORT="8000"
else
SERVE_PORT="$@"
fi
docker run -d --name w1 -v $(pwd):/root -w /root -p $SERVE_PORT:$SERVE_PORT python:alpine python -m http.server $SERVE_PORT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment