Skip to content

Instantly share code, notes, and snippets.

@mapio mapio/serve.sh
Created Apr 17, 2015

Embed
What would you like to do?
A small script to serve a local directory via HTTP
#!/bin/bash
# see http://veithen.github.io/2014/11/16/sigterm-propagation.html
trap 'kill -TERM $PID' TERM INT
python -m SimpleHTTPServer & PID=$!
python -m webbrowser -t "http://127.0.0.1:8000/"
wait $PID
trap - TERM INT
wait $PID
exit $?
@mapio

This comment has been minimized.

Copy link
Owner Author

commented Apr 17, 2015

Just go to the directory you want to serve and type serve.sh (if you have it in your path, or ./serve.sh if you have saved it in the directory are into). It will start the Python SimpleHTTPServer from the current directory and open the system web browser pointing it to the just started server; once done, hit ctrl-c and it will stop the running server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.