Skip to content

Instantly share code, notes, and snippets.

@ShopifyEng
Created March 25, 2021 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShopifyEng/806ffbda77cf449a701001a97ab8363f to your computer and use it in GitHub Desktop.
Save ShopifyEng/806ffbda77cf449a701001a97ab8363f to your computer and use it in GitHub Desktop.
How to Build a Web App with and without Rails Libraries
# mirth.rb
# HTTP Requests:
# Break down HTTP request from the client
# and displays it
require 'socket'
server = TCPServer.new(1337)
loop do
client = server.accept
request_line = client.readline
puts "The HTTP request line looks like this:"
puts request_line
method_token, target, version_number = request_line.split
response_body = "✅ Received a #{method_token} request to #{target} with #{version_number}"
client.puts response_body
client.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment