-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
81 lines (63 loc) · 1.07 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'sinatra'
require 'sinatra/reloader'
=begin
get '/hello/:name' do
"hello #{params[:name]}"
end
get '/hello/:name' do |n|
"hello #{n}"
end
get '/hello/:fname/:lname' do |f,l|
"hello #{f} #{l}"
end
get '/hello/:fname/:lname' do |f,l|
"hello #{f} #{l}"
end
get %r{/users/([0-9]*)} do |i|
"user id = #{i}"
end
get '/' do
erb :index
end
get '/:name' do |n|
@name = n
@title = "SinatraTutorial"
erb :index
end
get '/' do
@title = "main index"
@content = "main content"
erb :index
end
get '/about' do
@title = "about this page"
@content = "this page is...."
@email = "kuro@gmail.com"
erb :about
end
=end
before do
@author = "kuro"
end
before '/admin/*' do
@msg = "admin area!"
end
after do
logger.info "page displayed successfully"
end
helpers do
def strong(s)
"<strong>#{s}</strong>"
end
end
get '/' do
@title = "main index"
@content = "main content by " + @author
erb :index
end
get '/about' do
@title = "about this page"
@content = "this page is...." + strong(@author)
@email = "kuro@gmail.com"
erb :about
end