Last active
August 29, 2015 14:11
-
-
Save thibmaek/eadfae1c2549d0ee3899 to your computer and use it in GitHub Desktop.
HTTP Server with error check
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
### 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