Skip to content

Instantly share code, notes, and snippets.

@hoff2
Created August 8, 2013 21:04
Show Gist options
  • Save hoff2/6188714 to your computer and use it in GitHub Desktop.
Save hoff2/6188714 to your computer and use it in GitHub Desktop.
wrapping a sinatra app around a static web site
# for those times when you have a static web site but then it turns out you
# need a contact form or some such.
# just sticking the whole site in public/ gets you most of the way there --
# the web server just serves up anything it finds there without calling on
# your app for anything
# 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
# maybe in apache you could just Options +Indexes instead, i haven't tried that :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment