-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_madlibs.rb
42 lines (38 loc) · 768 Bytes
/
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
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} ran away with the #{color} #{object} "
end
__END__
@@questions
<!doctype html>
<html>
<header>
<title>Madlibs</title>
</header>
<body>
<form method="POST" action="/madlibs">
<p>Animal:</p>
<input name="animal">
<p>Color:</p>
<input name="color">
<p>Person:</p>
<input name="person">
<p>Object:</p>
<input name="object">
<p>Adjective:</p>
<input name="adjective">
<p>Verb:</p>
<input name="verb">
<input type="submit" value="Create Madlib">
</form>
</body>
</html>