Skip to content

Commit ddc30f0

Browse files
foohyfoohzpao
authored andcommitted
Only Read Comments File On Comments Route (reactjs#154)
1 parent 08115a6 commit ddc30f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727

2828
function routeRequest()
2929
{
30-
$comments = file_get_contents('comments.json');
3130
$uri = $_SERVER['REQUEST_URI'];
3231
if ($uri == '/') {
3332
echo file_get_contents('./public/index.html');
3433
} elseif (preg_match('/\/api\/comments(\?.*)?/', $uri)) {
34+
$comments = file_get_contents('comments.json');
3535
if($_SERVER['REQUEST_METHOD'] === 'POST') {
3636
$commentsDecoded = json_decode($comments, true);
3737
$commentsDecoded[] = [

0 commit comments

Comments
 (0)