Created
September 25, 2015 16:38
-
-
Save tdpreece/91c6b0305cc7a151e03f to your computer and use it in GitHub Desktop.
Running a Python SimpleHTTPServer in the background and killing it when doneSimpleHTTPServer
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
#!/usr/bin/env bash | |
# Create a page in the current dir | |
echo "My Test Page" > test.html | |
# Start server | |
python -m SimpleHTTPServer 8000 &> /dev/null & | |
pid=$! | |
# Give server time to start up | |
sleep 1 | |
# request page and print to stdout | |
wget -O - http://0.0.0.0:8000/test.html 2> /dev/null | |
# Stop server | |
kill "${pid}" | |
# Output on running script: | |
# My Test Page |
thx!
Great Example
Hey Guys! Great tip... I made a similar to use CGI:
python -m CGIHTTPServer 8000
(put the files under the /cgi-bin folder and apply chmod a+x to those files)
Very nice :D
Using Python3: python3 -m http.server --cgi 8009 &> /dev/null &
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice... thanks.