Created
April 17, 2015 07:46
-
-
Save mapio/7061f2b4bb344695a9ea to your computer and use it in GitHub Desktop.
A small script to serve a local directory via HTTP
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
#!/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 $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PythonSimpleHTTPServer
from the current directory and open the system web browser pointing it to the just started server; once done, hitctrl-c
and it will stop the running server.