Serving static files with Sinatra

You can use the send_file helper to serve files.

require 'sinatra'

get "https://stackoverflow.com/" do
  send_file File.join(settings.public_folder, 'index.html')
end

This will serve index.html from whatever directory has been configured as having your application’s static files.

Leave a Comment