我有以下代码,但是当我运行 main.rb 时没有任何显示:
require 'sinatra/base'
require 'sinatra/reloader'
class Site < Sinatra::Base
set :root, File.expand_path('../../', __FILE__) #converts path to absolute from here
files = Dir["#{:root}files/"]
get '/' do
files[1]
end
# start the server if ruby file executed directly
run! if app_file == $0
end
文件夹结构如下:
Site > lib > main.rb
Site > files > file1.txt file2.txt file3.txt