Created
November 16, 2012 17:22
-
-
Save drewkerrigan/4089178 to your computer and use it in GitHub Desktop.
Turn demo_service.rb into a web server
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
# 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