Skip to content

Instantly share code, notes, and snippets.

@jeygeethan
Created September 14, 2017 06:03
Show Gist options
  • Save jeygeethan/200cc0b71bd9d84b9adb24cf7131c43e to your computer and use it in GitHub Desktop.
Save jeygeethan/200cc0b71bd9d84b9adb24cf7131c43e to your computer and use it in GitHub Desktop.
Simple Tcp Http Server in Ruby
require 'socket'
server = TCPServer.new(1234)
while request = server.accept
puts request.gets
request.puts "HTTP/1.1 200 OK\r\n\r\nHello world!"
request.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment