Answers for "serve current directory from command line"

1

serve current directory from command line

#Simplest way possible (thanks Aaron Patterson/n0kada):

ruby -run -e httpd . -p 9090

# I have this in my  .bashrc :

function serve {
  port="${1:-3000}"
  ruby -run -e httpd . -p $port
}

# It serves the current directory on port 3000 by default, but you can also specify the port:

~ $ cd tmp
~/tmp $ serve      # ~/tmp served on port 3000
~/tmp $ cd ../www
~/www $ serve 5000   # ~/www served on port 5000
Posted by: Guest on June-18-2020

Code answers related to "serve current directory from command line"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language