Commit
This commit is contained in:
commit
3ccef121b8
7 changed files with 50 additions and 0 deletions
20
app.rb
Normal file
20
app.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require 'sinatra'
|
||||
require 'tilt/erb'
|
||||
|
||||
|
||||
set :public_folder, 'public'
|
||||
|
||||
class CorgBotApp < Sinatra::Base
|
||||
get '/' do
|
||||
extensions = ['.png', '.jpg', '.jpeg', '.gif']
|
||||
images = Dir.entries('public/images').delete_if { |x|
|
||||
extension = x[-4, 4]
|
||||
!extensions.index(extension)
|
||||
}
|
||||
|
||||
corgi = images[rand(images.length)]
|
||||
erb :index, :locals => {
|
||||
:corgi => corgi
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in a new issue