Created
September 14, 2017 06:03
-
-
Save jeygeethan/200cc0b71bd9d84b9adb24cf7131c43e to your computer and use it in GitHub Desktop.
Simple Tcp Http Server in Ruby
This file contains hidden or 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' | |
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