Created
February 2, 2012 03:00
-
-
Save JustinLove/1721135 to your computer and use it in GitHub Desktop.
Trivial web server in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
s=TCPServer.new(8888) | |
loop { | |
c=s.accept | |
f = 'public' + c.gets.split[1] | |
c<<"HTTP/1.0 200 OK\r\n\r\n#{File.read(f)rescue nil}" | |
c.close | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment