A server-side service outputs a long response using Sinatra's streaming API. The javascript client process this long response as a stream and refresh a pre in the HTML page until the whole response has been received.
The solution implemented here is due to @konstantinhaase. An somewhat uncomplete solution by @hearlamb and not relying on HTML5 EventSource can be found at https://gist.github.com/1476274
To run this one:
bundle install
bundle exec ruby app.rb