Last active
August 29, 2015 14:21
-
-
Save adriancuadros/2a221d2b0ea9a2fc5da8 to your computer and use it in GitHub Desktop.
HackerSchool 1-7 Solution (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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<link rel="stylesheet" type="text/css" href="./read.css"> | |
<title>Best gags</title> | |
</head> | |
<body> | |
<h1>Best gags</h1> | |
<div class='best-gag'> | |
<span>Joke with most points</span> | |
<h3><%= @reader.loved_gag.title %></h3> | |
<img src="<%= @reader.loved_gag.image_url %>" /> | |
</div> | |
<div class='commented-gag'> | |
<span>Joke with most comments</span> | |
<h3><%= @reader.commented_gag.title %></h3> | |
<img src="<%= @reader.commented_gag.image_url %>" /> | |
</div> | |
</body> | |
</html> |
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
## nine_app.rb | |
class NineApp | |
def initialize | |
@reader = GagReader.new | |
end | |
def render | |
ERB.new(File.read('./practice/practice.erb')).result(binding) | |
end | |
end | |
nineapp = -> (env) { [ '200', {'Content-Type' => 'text-html'}, [NineApp.new.render] ] } | |
Rack::Handler::WEBrick.run nineapp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment