meme_bot/meme_bot.rb
2015-05-17 13:53:53 -05:00

24 lines
492 B
Ruby

require 'json'
require 'workers/random_salutation'
require 'workers/animations'
get '/?' do
content_type :json
greeting = RandomSalutation.new
{ message: greeting.short }.to_json
end
get '/greet/:length/?' do
content_type :json
greeting = RandomSalutation.new
{ message: greeting.send(params[:length]) }.to_json
end
post '/animate/?' do
content_type :json
gif = Animations.new
@json = JSON.parse(request.body.read)
{ message: gif.find( @json['search'] ) }.to_json
end