diff --git a/server.rb b/server.rb index 8e40876d..b0e08601 100644 --- a/server.rb +++ b/server.rb @@ -16,7 +16,7 @@ puts "Server started: http://localhost:#{port}/" root = File.expand_path './public' -server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => root +server = WEBrick::HTTPServer.new Port: port, DocumentRoot: root server.mount_proc '/comments.json' do |req, res| comments = JSON.parse(File.read('./comments.json')) @@ -28,7 +28,7 @@ comment[key] = value.force_encoding('UTF-8') end comments << comment - File.write('./comments.json', JSON.pretty_generate(comments, :indent => ' ')) + File.write('./comments.json', JSON.pretty_generate(comments, indent: ' ')) end # always return json @@ -37,6 +37,6 @@ res.body = JSON.generate(comments) end -trap 'INT' do server.shutdown end +trap('INT') { server.shutdown } server.start