Skip to content

Instantly share code, notes, and snippets.

@xbalaji
Last active December 7, 2018 23:56
Show Gist options
  • Save xbalaji/9b647a760e5c54639a89ec17a4eabda6 to your computer and use it in GitHub Desktop.
Save xbalaji/9b647a760e5c54639a89ec17a4eabda6 to your computer and use it in GitHub Desktop.
python simple http server
startpyws ()
{
V=$(python -c 'import sys;print(sys.version_info.major)');
if [ "$V" == "2" ]; then
python -m SimpleHTTPServer;
else
python -m http.server;
fi
}
@anirudhb
Copy link

anirudhb commented Dec 7, 2018

This works better, and is a one-liner:

python -V 2>&1 | grep "Python 3" && python -m http.server || python -m SimpleHTTPServer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment