Skip to content

Instantly share code, notes, and snippets.

@shelling
Created February 16, 2010 08:46
Show Gist options
  • Select an option

  • Save shelling/305395 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/305395 to your computer and use it in GitHub Desktop.
Simplest Rack Application Example
#!/usr/bin/env ruby
require "rubygems"
require "rack"
require "rack/showexceptions"
require "rack/request"
require "rack/response"
class Hash
def htmlize
res = "{<br>"
self.each do |key,value|
res.concat " #{key} => #{value}<br>"
end
res.concat "}"
res
end
end
class Hello
def call(env)
req = Rack::Request.new(env)
[
200,
{"Content-Type" => "text/html"},
req.inspect
]
end
end
Rack::Handler::Mongrel.run Hello.new, :Port => 3000 if __FILE__ == $0
require "rack-simple"
use Rack::ShowExceptions
run Hello.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment