public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
require 'socket'
require 'celluloid'
 
class HTTPServer
include Celluloid
 
def initialize(port)
@port = port
end
 
def start
@server = TCPServer.new(@port)
loop {
client = @server.accept
headers = "HTTP/1.1 200 OK\r\nDate: Tue, 14 Dec 2010 10:48:45 GMT\r\nServer: Ruby\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n"
client.puts headers
client.puts "<html></html>"
client.close
}
end
end
 
hs = HTTPServer.new 3000
hs.start

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.