Created
March 29, 2011 04:07
-
-
Save jcamenisch/891792 to your computer and use it in GitHub Desktop.
serve on heroku
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
#\ -p 4000 | |
require 'serve' | |
require 'serve/rack' | |
require 'json' | |
# The project root directory | |
root = ::File.dirname(__FILE__) | |
# Rack Middleware | |
use Rack::ShowStatus # Nice looking 404s and other messages | |
use Rack::ShowExceptions # Nice looking errors | |
use Rack::Static, :urls => ["/images", "/javascripts", "/stylesheets"], :root => "public" | |
# Compass | |
if ENV['RACK_ENV'] == "development" | |
require 'sass/plugin/rack' | |
require 'compass' | |
Compass.add_project_configuration(root + '/compass.config') | |
Compass.configure_sass_plugin! | |
use Sass::Plugin::Rack # Compile Sass on the fly | |
end | |
# Rack Application | |
if ENV['SERVER_SOFTWARE'] =~ /passenger/i | |
# Passendger only needs the adapter | |
run Serve::RackAdapter.new(root + '/views') | |
else | |
# We use Rack::Cascade and Rack::Directory on other platforms to handle static | |
# assets | |
run Rack::Cascade.new([ | |
Serve::RackAdapter.new(root + '/views'), | |
Rack::Directory.new(root + '/public') | |
]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment