Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Sinatra application for serving simple Single Page Applications

View gist:3594414
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
require 'bundler/setup'
Bundler.require
 
class Application < Sinatra::Base
get '/assets/:file' do
env['PATH_INFO'].gsub!("/assets","")
asset_handler.call(env)
end
 
get '/' do
erb :index
end
 
private
def project_root
@project_root ||= File.expand_path File.dirname(__FILE__)
end
 
def asset_handler
@asset_handler ||= create_asset_handler
end
 
def create_asset_handler
handler = Sprockets::Environment.new(project_root)
handler.cache = Sprockets::Cache::FileStore.new("/tmp")
handler.append_path(File.join(project_root, 'src/javascripts'))
handler.append_path(File.join(project_root, 'src/stylesheets'))
handler
end
end
 
run Application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.