Created
February 16, 2010 08:46
-
-
Save shelling/305395 to your computer and use it in GitHub Desktop.
Simplest Rack Application Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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