Skip to content

Instantly share code, notes, and snippets.

@DavidBechtel
Created January 24, 2013 01:26
Show Gist options
  • Save DavidBechtel/4616735 to your computer and use it in GitHub Desktop.
Save DavidBechtel/4616735 to your computer and use it in GitHub Desktop.
adaptation of Bill Gathen's sinatra code
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
@DavidBechtel
Copy link
Author

I took what Bill Gathen had done for his fizz buzzer app and adapted it to my fizz buzz process. Thanks Bill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment