Created
November 27, 2009 09:23
-
-
Save aerith/243921 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'sinatra' | |
require 'haml' | |
require 'pathname' | |
get '*' do | |
base = Pathname.new(File.dirname(__FILE__)).parent | |
path = @params[:splat].first.gsub(/^\//, '') | |
if path !~ /\/$/ then | |
name = path + '.haml' | |
file = base + name | |
if file.file? && file.readable? then | |
return Haml::Engine.new(file.readlines.join('')).render | |
end | |
end | |
status 404 | |
end | |
set :run => false | |
set :environment => :cgi | |
Rack::Handler::CGI.run Sinatra::Application | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment