-
-
Save creativeaura/5546765 to your computer and use it in GitHub Desktop.
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
# Start an HTTP server from a directory, optionally specifying the port | |
function server() { | |
# Default to port 8000 | |
local port="${1:-8000}" | |
# Since the one-liner blocks, we open the browser beforehand. However, we want to | |
# wait just a couple of seconds since the server will not be ready just yet. | |
# Also, I think Linux users should be able to use 'xdg-open' ('open' is for OS X). | |
( sleep 2; open "http://localhost:${port}/" ) & | |
python -m SimpleHTTPServer "$port" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment