Created
January 24, 2013 01:26
-
-
Save DavidBechtel/4616735 to your computer and use it in GitHub Desktop.
adaptation of Bill Gathen's sinatra code
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
require 'sinatra' | |
require './fizzbuzz_generator' | |
require './presents' | |
get '/' do | |
<<EOF | |
<html> | |
<body> | |
<h1>FizzBuzz!</h1> | |
<form method="post"> | |
<p>Fizzbuzz up to <input type="text" name="last_num" value="15">. Display as | |
<select name="format"> | |
<option>text</option> | |
<option>json</option> | |
<option>html</option> | |
</select> | |
<input type="submit" value="Now, do it!"> | |
</p> | |
</form> | |
</body> | |
</html> | |
EOF | |
end | |
post '/' do | |
DisplayFizzBuzz = Presents.new(FizzBuzzGenerator.new(params[:last_num])) | |
puts "FORMAT: " + params[:format] | |
h1="Dave Bechtel's Fizzbuzz" | |
if params[:format] == "text" | |
DisplayFizzBuzz.as_text | |
elsif params[:format] == "json" | |
DisplayFizzBuzz.as_json | |
elsif params[:format] == "html" | |
DisplayFizzBuzz.as_html | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I took what Bill Gathen had done for his fizz buzzer app and adapted it to my fizz buzz process. Thanks Bill.