Created
December 4, 2010 19:51
-
-
Save robertsosinski/728429 to your computer and use it in GitHub Desktop.
Short Stack: A simple ruby stack server.
This file contains 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 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
meth, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, [send(meth, *attrs).to_s]] | |
end | |
end | |
self | |
end | |
end | |
Rack::Handler::WEBrick.run [].webapp, :Port => 9292 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment