-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
31 lines (24 loc) · 809 Bytes
/
app.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
# app.rb
$:.unshift "#{File.dirname(__FILE__)}"
require './lib/sinatra'
get '/' do
['200', {'Content-Type' => 'text/html'}, ['You are in the root page.']]
end
get '/posts' do
['200', {'Content-Type' => 'text/html'}, ['You are in the posts page.']]
end
get '/posts/:post_id' do
id = params["post_id"]
['200', {'Content-Type' => 'text/html'}, ["You are reading post number #{id}."]]
end
get %r{\/comments\/([\d]+)} do
id = params["captures"].first
['200', {'Content-Type' => 'text/html'}, ["You are reading comment number #{id}."]]
end
get '/*/comments' do
content = params["splat"].first
['200', {'Content-Type' => 'text/html'}, ["You are reading comments for \"#{content}\"."]]
end
post '/posts' do
['200', {'Content-Type' => 'text/html'}, ["You just posted to the posts page."]]
end