-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_madlibs.rb
46 lines (40 loc) · 1.15 KB
/
web_madlibs.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 'sinatra'
get '/madlibs' do
erb :questions
end
post '/madlibs' do
animal = params[:animal]
color = params[:color]
person = params[:person]
object = params[:object]
adjective = params[:adjective]
verb = params[:verb]
"The #{adjective} #{animal} started to #{verb} because the #{person} run away with the #{color} #{object}"
end
__END__
@@questions
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Madlibs</title>
</head>
<body>
<form method="POST" action="/madlibs">
<label for="animal">Animal</label>
<input type="text" name="animal" id="animal" /><br />
<label for="color">Color</label>
<input type="text" name="color" id="color" /><br />
<label for="person">Person</label>
<input type="text" name="person" id="person" /><br />
<label for="object">Object</label>
<input type="text" name="object" id="object" /><br />
<label for="adjective">Adjective</label>
<input type="text" name="adjective" id="adjective" /><br />
<label for="verb">Verb</label>
<input type="text" name="verb" id="verb" />
<hr />
<input type="submit" value="Submit" />
</form>
</body>
</html>