Creating a HTTP Server with ruby in 7 LOC
i usually face a problem, while being an instructor for ruby on rails i want to share files with audience, so flash stick or memroy card is not optional, and all of them downloading the file from the internet would take ages with our egyptian lines speed, so i fire up this script and let them enter to my IP address and download the files to their machines :)
require 'webrick'
Port = 3000
Directory = Dir::pwd
WEBrick::HTTPServer.new(
Port: Port,
DocumentRoot: Directory
).start
Written by Emad Elsaid
Related protips
4 Responses
With Femtows : 2 lines, ans add some
get('/path') { code }
over 1 year ago
·
:) i have seen it today, good job Raubarede, i like it.
over 1 year ago
·
How about with one line?
ruby -run -e httpd . -p 3000
:)
over 1 year ago
·
yup, that works like charm :D, thanks
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#