Skip to content

Instantly share code, notes, and snippets.

@carllerche
Forked from smathy/gist:258378
Created December 17, 2009 05:03
Show Gist options
  • Save carllerche/258536 to your computer and use it in GitHub Desktop.
Save carllerche/258536 to your computer and use it in GitHub Desktop.
# sudo gem install rack nokogiri mongrel --no-rdoc --no-ri
# curl http://gist.github.com/raw/258378/31dc0cc39faf8328cc6b5b5e2fa2a973153f174d/gistfile1.txt > hello_world.rb
# ruby hello_world.rb
require 'rubygems'
require 'rack'
require 'nokogiri'
require 'open-uri'
class HelloWorld
def call(env)
lines = Nokogiri::HTML(open('http://stannard.net.au/blog/index.cfm/2009/11/3/Hello-World-with-ColdFusion-and-Spring')).css('div.code').to_s.count("\n")
[ 200, { "Content-type" => "text/plain" }, "How can it take #{lines} lines to say Hello?" ]
end
end
Rack::Handler::Mongrel.run HelloWorld.new, :Port => 8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment