Building a simple web server with Ruby socket. This web server is in its simplest form. Listening at port 4567, accept GET request, response with “Hello World”, reject all other request with “Forbidden”.

require 'socket'def response(client, status, headers, body)
client.print "HTTP/1.1 #{status}\r\n"
headers.each do |key, value|
client.print "#{key}: #{value}\r\n"
client.print "\r\n"
body.each do |part|
client.print part
end 4567
puts "server started"
loop do
Thread.start(server.accept) do |client|…