-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.rb
More file actions
32 lines (27 loc) · 700 Bytes
/
web.rb
File metadata and controls
32 lines (27 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby
require "ruby_cowsay"
require "fortune"
require "sinatra"
get "/" do
msg = params[:msg] ||
"usage: \n" +
" GET /?msg=sup\n" +
" GET /?msg=hello&cow=stegosaurus\n" +
" GET /?msg=yikes&face=paranoid\n" +
"\n" +
"cows: #{Cow.cows.join(" ")}\n" +
"\n" +
"faces: #{Cow.faces.join(" ")}"
cow_type = params[:cow] || "default"
face_type = params[:face] || "default"
content_type "text/plain"
Cow.say(msg, cow_type, face_type)
end
get "/fortune" do
msg = Fortune.get
cow_type = params[:cow] || "default"
face_type = params[:face] || "default"
p msg
content_type "text/plain"
Cow.say(msg, cow_type, face_type)
end