Skip to content

Instantly share code, notes, and snippets.

@failshell

failshell/api.rb Secret

Created September 1, 2015 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save failshell/ef7e34cc3d56457974b4 to your computer and use it in GitHub Desktop.
Save failshell/ef7e34cc3d56457974b4 to your computer and use it in GitHub Desktop.
require 'sinatra/base'
class Robut::API < Sinatra::Base
set :server, 'thin'
set :connections, []
set :logging, false
get '/logs', provides: 'text/event-stream' do
stream :keep_open do |out|
settings.connections << out
out.callback { settings.connections.delete(out) }
end
end
post '/input' do
settings.connections.each { |out| out << "#{params[:log]}\n" }
204
end
end
/Users/user/.rvm/gems/ruby-2.2.2/gems/sinatra-1.4.4/lib/sinatra/base.rb:1764:in `detect_rack_handler': Server handler (thin) not found. (RuntimeError)
from /Users/.rvm/gems/ruby-2.2.2/gems/sinatra-1.4.4/lib/sinatra/base.rb:1420:in `run!'
from ./bin/robut:15:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment