Created
August 8, 2013 21:04
-
-
Save hoff2/6188714 to your computer and use it in GitHub Desktop.
wrapping a sinatra app around a static web site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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