Skip to content

Commit b093b34

Browse files
committed
read _comments.json after request received
The _comments.json file was getting cached and would not update the view when the json was changed.
1 parent 558e0c7 commit b093b34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
require 'webrick'
1212
require 'json'
1313

14-
comments = react_version = JSON.parse(File.read('./_comments.json'))
15-
1614
puts 'Server started: http://localhost:3000/'
1715

1816
root = File.expand_path './public'
1917
server = WEBrick::HTTPServer.new :Port => 3000, :DocumentRoot => root
2018

2119
server.mount_proc '/comments.json' do |req, res|
20+
comments = react_version = JSON.parse(File.read('./_comments.json'))
21+
2222
if req.request_method == 'POST'
2323
# Assume it's well formed
2424
comments << req.query

0 commit comments

Comments
 (0)