Skip to content

Instantly share code, notes, and snippets.

@defp
Last active December 23, 2015 17:49
Show Gist options
  • Select an option

  • Save defp/6671288 to your computer and use it in GitHub Desktop.

Select an option

Save defp/6671288 to your computer and use it in GitHub Desktop.
rack example
require 'rack'
def pp(env)
env.map {|key, value| "#{key} => #{value}"}.sort.join("<br/>")
end
Rack::Handler::WEBrick.run lambda {|env| [200, {"Content-type" => "text/html"}, [pp(env)]]}, :Port => 300
require 'rack'
rackapp = lambda {|env|
request = Rack::Request.new env
response = Rack::Response.new
response.body << "hello"
response.finish
}
Rack::Handler::WEBrick.run rackapp, :Port => 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment