-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhunt.rb
46 lines (38 loc) · 1009 Bytes
/
hunt.rb
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'rubygems'
require 'sinatra'
get '/' do
"The chase is on!\nGET /page2\n"
end
get '/page2' do
"You are at page two. Good for you.\nCheck out the 404 page!\n"
end
error 404 do
"error, can haz no page :(\nbut try this one: /negotiate\n"
end
get '/negotiate' do
if request.accept? 'text/plain'
headers "Content-Type" => "text/plain"
"ask me for text/html\n"
else
headers "Content-Type" => "text/html"
"<p><strong>Good job!</strong> For next clue " +
"go <a href=\"/here\">there</a>.</p>\n"
end
end
get '/here' do
redirect to('/somewhere')
end
get '/somewhere' do
"Hey there. Your next clue is '/concert'.\n"
end
get '/concert' do
"Post your name please. Also, send key=dingbat.\n"
end
post '/concert' do
if params['key'] == 'dingbat' and params['name']
"Hey #{params['name']}! Welcome to the concert!\n" +
"The end. You win.\n"
else
"Your ticket is no good here. Try again.\n"
end
end