-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
30 lines (22 loc) · 668 Bytes
/
app.rb
File metadata and controls
30 lines (22 loc) · 668 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
require 'page'
class App
def call(env)
request = Rack::Request.new(env)
response = Rack::Response.new
response['Content-Type'] = 'text/html'
# Since this is a one-page website, we don't even bother to check the path.
if request.get? # visiting the page
page = Page.new
response.write page.html
elsif request.post? # pressing the convert button
page = Page.new
page.mode = :post
page.color = request.params["color"]
response.write page.html
else
response.status = 405
response.write "I'm sorry Dave, I'm afraid I can't do that."
end
response.finish
end
end