Skip to content

Instantly share code, notes, and snippets.

@MatiasFernandez
Created March 1, 2020 15:04
Show Gist options
  • Save MatiasFernandez/ed188ec4cb9f8a11b3cba6f67427bff8 to your computer and use it in GitHub Desktop.
Save MatiasFernandez/ed188ec4cb9f8a11b3cba6f67427bff8 to your computer and use it in GitHub Desktop.
Basic Ruby Echo HTTP Server
#!/usr/bin/ruby
# run like ./http-server.rb 8000
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => ARGV.first)
server.mount_proc '/' do |req, res|
puts req.header
puts req.body
end
trap 'INT' do
server.shutdown
end
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment