wrap a sinatra app around a static website
For those times when you have a static web site but then it turns out you need to add a contact form or some such. Just sticking the whole site in public/ gets you most of the way there -- but that doesn't work for the default index.html page for paths like "/" or "/foo". So to catch those, you could use this as the very last route/action in your app, as a default/catch-all.
get '/*' do
path = params[:splat].first
path = File.join('public', path, 'index.html')
send_file path
end
Written by Charles Hoffman
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#