Last active
October 3, 2022 08:09
-
-
Save IanVaughan/5af63a0b10c0a6cbfd289e95590f53ff to your computer and use it in GitHub Desktop.
Simple ruby server
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' | |
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