Skip to content

Instantly share code, notes, and snippets.

@HusseinMorsy
Created March 17, 2009 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HusseinMorsy/80565 to your computer and use it in GitHub Desktop.
Save HusseinMorsy/80565 to your computer and use it in GitHub Desktop.
A simpe rack example
# simple rack-example
# for more see
# http://m.onkey.org/2008/11/17/ruby-on-rack-1
# and
# http://m.onkey.org/2008/11/18/ruby-on-rack-2-rack-builder
require 'rubygems'
require 'rack'
class HelloWorld
def call(env)
case env["REQUEST_PATH"]
when "/"
[200, {"Content-Type" => "text/html"}, 'index']
when "/demo/goodby.php"
[200, {"Content-Type" => "text/html"}, "goodby"]
else
[404, {"Content-Type" => "text/html"}, "Not found"]
end
end
end
Rack::Handler::Mongrel.run HelloWorld.new, :Port => 9292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment