假设我的目录结构类似于:
path_to_file/one/index.html
如何将我的 sinatra 应用程序设置为路由到
mysite.com/path_to_file/one/
并有前面提到的文件来渲染?path_to_file
将始终保持不变,但其中会有不同的文件夹(two
、three
等)。
我尝试了以下方法:
get '/path_to_file/:number' do
File.read(File.join('path_to_file', "#{params[:number]}", "index.html"))
end
但随后链接自的例如 javascript 文件index.html
无法正确呈现。