-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ru
62 lines (56 loc) · 1.18 KB
/
config.ru
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
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
class MainResponder
def index env
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
end
def accelerometer env
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
end
def accelerometer env
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/charts.html', File::RDONLY)
]
end
end
def path_regex base = nil
if nil
# root path option leading /
/^\/?$/
else
/^\/#{base}\/?$/
end
end
run lambda { |env|
responder = MainResponder.new
path = env['PATH_INFO']
if path_regex.match path
responder.index env
elsif path_regex('accelerometer').match(path)
responder.accelerometer env
elsif path_regex('charts').match(path)
responder.accelerometer env
else
[404, {}, File.open('public/404.html', File::RDONLY)]
end
}