Skip to content

Instantly share code, notes, and snippets.

@ntulip
Created June 4, 2012 15:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ntulip/2869069 to your computer and use it in GitHub Desktop.
Static Sites on Heroku
# From http://anti-pattern.com/2012/6/2/static-sites-on-heroku
# Gemfile
source "http://rubygems.org"
gem "rack"
# config.ru
require "rubygems"
require "bundler"
Bundler.require(:default)
map "/" do
use Rack::Static, urls: ["/assets"], root: Dir.pwd
run lambda { |env|
headers = {
"Content-Type" => "text/html",
"Cache-Control" => "public, max-age=86400"
}
body = File.open("#{Dir.pwd}/index.html", File::RDONLY).read
[200, headers, [body]]
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment