Skip to content

Instantly share code, notes, and snippets.

@shmdt
Forked from kinopyo/sinatra_render_html.rb
Created May 24, 2017 08:25
Show Gist options
  • Save shmdt/bcb474823ceeb97bfc34c5477c2e0814 to your computer and use it in GitHub Desktop.
Save shmdt/bcb474823ceeb97bfc34c5477c2e0814 to your computer and use it in GitHub Desktop.
How to render static HTML files in Sinatra.
require 'sinatra'
get '/' do
File.read(File.join('public', 'index.html'))
# or
# send_file File.join(settings.public, 'index.html')
end
require "sinatra"
get '/' do
# File.read(File.join('public', 'index.html'))
html :index
end
def html(view)
File.read(File.join('public', "#{view.to_s}.html"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment