Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 10, 2022 20:49
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 havenwood/ffcfd263ebcb9ea1c54fe5daad51ff4e to your computer and use it in GitHub Desktop.
Save havenwood/ffcfd263ebcb9ea1c54fe5daad51ff4e to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
code = 200
headers = {'content-type' => 'text/plain'}.freeze
body = lambda do |stream|
clock = %w[tick tock].cycle
42.times do
stream.write clock.next
stream.write "\n"
sleep 1
end
stream.close
end.freeze
run ->(_env) { [code, headers, body] }.freeze
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'rack', github: 'rack/rack'
gem 'puma', github: 'puma/puma'
ruby -rhttp -e "HTTP.get('http://0.0.0.0:9292').body.each { |message| print message }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment