Created
June 8, 2010 06:22
-
-
Save EmmanuelOga/429680 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
# [sudo] gem install rack | |
# ruby -rubygems server.rb | |
# open http://localhost:9292 in browser. | |
require 'rack' | |
require 'erb' | |
TEMPLATE = File.read("template.erb") | |
server = lambda do |env| | |
response_text = ERB.new(TEMPLATE).result | |
response_code = "200" | |
response_headers = {"Content-Type" => "text/html", "Content-Length" => response_text.length.to_s} | |
[response_code, response_headers, response_text] | |
end | |
Rack::Handler::WEBrick.run server, :Port => 9292 |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<title> | |
Vare minimal erb page. | |
</title> | |
</head> | |
<body> | |
Ruby says that 2 + 2 is: | |
<br/> | |
<%= 2 + 2%> | |
<% [1,2,3,4].each do |n| %> | |
<h<%= n %>>And these are headers.</h<%= n %>> | |
<% end %> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment