File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 16
16
puts "Server started: http://localhost:#{ port } /"
17
17
18
18
root = File . expand_path './public'
19
- server = WEBrick ::HTTPServer . new : Port => port , : DocumentRoot => root
19
+ server = WEBrick ::HTTPServer . new Port : port , DocumentRoot : root
20
20
21
21
server . mount_proc '/comments.json' do |req , res |
22
22
comments = JSON . parse ( File . read ( './comments.json' ) )
28
28
comment [ key ] = value . force_encoding ( 'UTF-8' )
29
29
end
30
30
comments << comment
31
- File . write ( './comments.json' , JSON . pretty_generate ( comments , : indent => ' ' ) )
31
+ File . write ( './comments.json' , JSON . pretty_generate ( comments , indent : ' ' ) )
32
32
end
33
33
34
34
# always return json
37
37
res . body = JSON . generate ( comments )
38
38
end
39
39
40
- trap 'INT' do server . shutdown end
40
+ trap ( 'INT' ) { server . shutdown }
41
41
42
42
server . start
You can’t perform that action at this time.
0 commit comments