Created
June 4, 2012 15:33
-
-
Save ntulip/2869069 to your computer and use it in GitHub Desktop.
Static Sites on Heroku
This file contains hidden or 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
# 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