Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Last active October 3, 2022 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/5af63a0b10c0a6cbfd289e95590f53ff to your computer and use it in GitHub Desktop.
Save IanVaughan/5af63a0b10c0a6cbfd289e95590f53ff to your computer and use it in GitHub Desktop.
Simple ruby server
require 'socket'
socket = TCPServer.new(4040)
loop do
client = socket.accept
first_line = client.gets
verb, path, _ = first_line.split
if verb == 'GET'
response = "HTTP/1.1 200\r\n\r\nHello!"
client.puts(response)
end
client.close
end
socket.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment