Skip to content

Instantly share code, notes, and snippets.

@bytearchive
Forked from tdpreece/simple_http_server.sh
Created September 1, 2016 21:42
Show Gist options
  • Save bytearchive/5aa272a1f309be81b09b0cfb5c481648 to your computer and use it in GitHub Desktop.
Save bytearchive/5aa272a1f309be81b09b0cfb5c481648 to your computer and use it in GitHub Desktop.
Running a Python SimpleHTTPServer in the background and killing it when doneSimpleHTTPServer
#!/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