-
-
Save bytearchive/5aa272a1f309be81b09b0cfb5c481648 to your computer and use it in GitHub Desktop.
Running a Python SimpleHTTPServer in the background and killing it when doneSimpleHTTPServer
This file contains hidden or 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment