Skip to content

Instantly share code, notes, and snippets.

@JustinLove
Created February 2, 2012 03:00
Show Gist options
  • Save JustinLove/1721135 to your computer and use it in GitHub Desktop.
Save JustinLove/1721135 to your computer and use it in GitHub Desktop.
Trivial web server in Ruby
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