Skip to content

Instantly share code, notes, and snippets.

@Aeon
Last active August 29, 2015 14:27
Show Gist options
  • Save Aeon/d5b1183716b13e4d1edc to your computer and use it in GitHub Desktop.
Save Aeon/d5b1183716b13e4d1edc to your computer and use it in GitHub Desktop.
minimal logserver

minimal logserver using sinatra

first, install gems

gem install sinatra thin

then start server with

ruby logserver.rb -p 9000

post data with:

curl --data '{"log":1,"foo":"bar"}' http://localhost:9000/

check contents of log.json, or open http://localhost:9000/ in browser to see log contents

require 'sinatra'
logfile = 'log.json'
get '/' do
send_file logfile, :type => :text
end
post '/' do
File.open(logfile, 'a') do |filehandle|
filehandle.puts(request.body.read)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment