Skip to content

Instantly share code, notes, and snippets.

@futur
Forked from tdpreece/simple_http_server.sh
Created June 21, 2016 02:10
Show Gist options
  • Save futur/a1176514fcff73d459fc62622335b81f to your computer and use it in GitHub Desktop.
Save futur/a1176514fcff73d459fc62622335b81f 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