Created
April 21, 2011 17:09
-
-
Save chischaschos/935008 to your computer and use it in GitHub Desktop.
One File Web Page with Rack
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
rvm 1.9.2@rack-examples --create |
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
source :gemcutter | |
gem 'haml' | |
gem 'rack' |
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
GEM | |
remote: http://rubygems.org/ | |
specs: | |
haml (3.0.25) | |
rack (1.2.2) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
haml | |
rack |
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
message = "Hello world" | |
headers = {"Content-Length" => "#{message.length}", | |
"Content-Type" => 'text/html'} | |
status = 200 | |
run lambda {[status, headers, [message]]} |
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
message = "Hello world" | |
status = 200 | |
use Rack::ContentLength | |
use Rack::ContentType | |
run lambda {[status, {}, [message]]} |
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
require 'erb' | |
status = 200 | |
home_view = <<VIEW | |
Hello world | |
VIEW | |
rendered_view = ERB.new(home_view).result | |
use Rack::ContentLength | |
use Rack::ContentType | |
run lambda {[status, {}, [rendered_view]]} |
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
require 'haml' | |
status = 200 | |
home_view = <<VIEW | |
!!! | |
%html | |
%head | |
%title= title | |
%body | |
= message | |
VIEW | |
rendered_view = Haml::Engine.new(home_view).render Object.new, | |
{:message => 'Hello world', :title => 'A hello world page'} | |
use Rack::ContentLength | |
use Rack::ContentType | |
run lambda {[status, {}, [rendered_view]]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment