Skip to content

Commit

Permalink
playing with Sinatra/Stream from sinatra-contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
crguezl committed Nov 19, 2014
1 parent b4f4799 commit db39582
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chapter2/streaming/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
set server: 'thin'
#set server: 'unicorn'

before do
content_type :txt
end

get '/' do
stream do |out|
puts out.class
out.puts "Hello World!", "How are you?"
sleep 1
out.write "Written #{out.pos} bytes so far!\n"
sleep 1
out.putc(65) unless out.closed?
sleep 1
out.puts "\nEnd of the Story"
out.flush
end
end

0 comments on commit db39582

Please sign in to comment.