# The 'map' keyword in the DSL tells Rack that any time a request that starts with "/foo" comes in, it should use the app contained inside this block (which Rack finds by #call'ing the block passed to 'map' at start up.
# This is setup that will occur when Rack first #call's the block
run Proc.new {|env| [200, {"Content-Type" => "text/html"}, $text ] }
# The 'run' keyword tells Rack that the argument following 'run' is the "app object". In this case, you've provided a Proc object. Each HTTP request that comes in, with a path starting with "/foo", will #call this Proc object. Put your "print $text" line inside the block passed to Proc.new, and you'll see it getting called each time.