This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!

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

By: uriel1998 on Apr 20th, 2012  |  syntax: Bash  |  size: 0.55 KB  |  views: 79  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data