Skip to content

Instantly share code, notes, and snippets.

@thibmaek
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thibmaek/eadfae1c2549d0ee3899 to your computer and use it in GitHub Desktop.
Save thibmaek/eadfae1c2549d0ee3899 to your computer and use it in GitHub Desktop.
HTTP Server with error check
### Thibault Maekelbergh ###
### http://blog.thibmaekelbergh.be/2014/12/18/http-python-server.html ###
cd "$(dirname "$0")" #Get current directory
ENTRY=index.html #Set the entry point for the server
if [ -f "$ENTRY" ]; then #Check if the entry exists then go on
sleep 1 && open "http://localhost:8000/"; #Delay a second then open localhost
python -m SimpleHTTPServer; #Start the HTTP Server
else #Send an alert
osascript -e 'display notification "No entry point found, quitting." with title "Missing index.html"'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment