Skip to content

Instantly share code, notes, and snippets.

@Beefster09
Last active September 10, 2020 15:44
Show Gist options
  • Save Beefster09/58b526d5f11b3e173a4d611e30660dd4 to your computer and use it in GitHub Desktop.
Save Beefster09/58b526d5f11b3e173a4d611e30660dd4 to your computer and use it in GitHub Desktop.
Bash function for serving any directory with Python
# Little snippet for serving a directory with a simple http server
# This intended to be source'd from .bashrc
function serve-dir {
(
cd "${1:-.}" &&\
python3 -m http.server "${2:-8080}"
)
}
# serve-dir snippet by Justin Snyder
# To the extent possible under law, the person who associated CC0 with
# serve-dir snippet has waived all copyright and related or neighboring rights
# to serve-dir snippet.
# You should have received a copy of the CC0 legalcode along with this
# work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment