Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (18 sloc) 370 Bytes
require 'sinatra'
require 'json'
@@data = []
@@count = 0
get '/' do
File.read(File.join('public', 'index.html'))
end
get '/messages' do
content_type :json
{:models => @@data }.to_json
end
post '/messages' do
content_type :json
puts params
message = JSON.parse(request.body.read.to_s).merge(:id => @@count += 1 )
@@data << message
message.to_json
end
Something went wrong with that request. Please try again.