Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
Created November 16, 2012 17:22
Show Gist options
  • Save drewkerrigan/4089178 to your computer and use it in GitHub Desktop.
Save drewkerrigan/4089178 to your computer and use it in GitHub Desktop.
Turn demo_service.rb into a web server
# Static files
get '/:file.:ext' do
case :ext
when "css"
content_type 'text/css'
when "js"
content_type 'text/javascript'
when "html"
content_type 'text/html'
when "gif"
content_type 'image/gif'
when "png"
content_type 'image/png'
when "ico"
content_type 'image/x-icon'
else
halt 404
end
File.read(File.join('public', "#{params[:file]}.#{params[:ext]}"))
end
get '/' do
content_type 'text/html'
File.read(File.join('public', "index.html"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment