SHARE
TWEET

BASH script to call when using Python's built-in HTTP server

uriel1998 Apr 20th, 2012 173 Never
  1. #!/bin/bash
  2.  
  3. # To be used to call Python's simple HTTP server.
  4.  
  5. localip=$(ifconfig | grep -e addr: | grep -e Bcast | awk '{print $2}'| awk -F ":" '{print $2}')
  6. echo "This script will start a webserver at"
  7. echo "$localip on port 8000 showing"
  8. echo "$PWD.  Do you want to continue [y/N]?"
  9. read CHOICE
  10. case "$CHOICE" in
  11.         [Yy]*)
  12.                 notify-send --icon=notification-network-wireless-full "Serving $PWD on port 8000"
  13.                 python -m SimpleHTTPServer
  14.                 notify-send --icon=notification-network-wireless-disconnected "Stopped sharing $PWD"
  15.         ;;
  16.         *)
  17.         ;;
  18. esac
RAW Paste Data
Top