Created
August 31, 2011 19:01
-
-
Save markbates/1184400 to your computer and use it in GitHub Desktop.
Sprockets with a simple Rack app
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
require 'sprockets' | |
project_root = File.expand_path(File.dirname(__FILE__)) | |
assets = Sprockets::Environment.new(project_root) do |env| | |
env.logger = Logger.new(STDOUT) | |
end | |
assets.append_path(File.join(project_root, 'app', 'assets')) | |
assets.append_path(File.join(project_root, 'app', 'assets', 'javascripts')) | |
assets.append_path(File.join(project_root, 'app', 'assets', 'stylesheets')) | |
map "/assets" do | |
run assets | |
end | |
map "/" do | |
run lambda { |env| | |
[ | |
200, | |
{ | |
'Content-Type' => 'text/html', | |
'Cache-Control' => 'public, max-age=86400' | |
}, | |
File.open('public/index.html', File::RDONLY) | |
] | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment