meme_bot/meme_bot.rb

24 lines
492 B
Ruby
Raw Normal View History

2015-05-16 21:47:18 -05:00
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