Skip to content

Commit 6590ed4

Browse files
committed
Merge pull request reactjs#29 from mecampbellsoup/master
Remove confusing underscore from comments.json filename
2 parents 13a46a2 + fb15f9c commit 6590ed4

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

_comments.json comments.json

File renamed without changes.

server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type comment struct {
1717
Text string `json:"text"`
1818
}
1919

20-
const dataFile = "./_comments.json"
20+
const dataFile = "./comments.json"
2121

2222
var commentMutex = new(sync.Mutex)
2323

server.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ app.use(bodyParser.json());
2121
app.use(bodyParser.urlencoded({extended: true}));
2222

2323
app.get('/comments.json', function(req, res) {
24-
fs.readFile('_comments.json', function(err, data) {
24+
fs.readFile('comments.json', function(err, data) {
2525
res.setHeader('Content-Type', 'application/json');
2626
res.send(data);
2727
});
2828
});
2929

3030
app.post('/comments.json', function(req, res) {
31-
fs.readFile('_comments.json', function(err, data) {
31+
fs.readFile('comments.json', function(err, data) {
3232
var comments = JSON.parse(data);
3333
comments.push(req.body);
34-
fs.writeFile('_comments.json', JSON.stringify(comments, null, 4), function(err) {
34+
fs.writeFile('comments.json', JSON.stringify(comments, null, 4), function(err) {
3535
res.setHeader('Content-Type', 'application/json');
3636
res.setHeader('Cache-Control', 'no-cache');
3737
res.send(JSON.stringify(comments));

server.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
function routeRequest()
1313
{
14-
$comments = file_get_contents('_comments.json');
14+
$comments = file_get_contents('comments.json');
1515
switch($_SERVER["REQUEST_URI"]) {
1616
case '/':
1717
echo file_get_contents('./public/index.html');
@@ -23,7 +23,7 @@ function routeRequest()
2323
'text' => $_POST['text']];
2424

2525
$comments = json_encode($commentsDecoded, JSON_PRETTY_PRINT);
26-
file_put_contents('_comments.json', $comments);
26+
file_put_contents('comments.json', $comments);
2727
}
2828
header('Content-Type: application/json');
2929
header('Cache-Control: no-cache');

server.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
@app.route('/comments.json', methods=['GET', 'POST'])
1818
def comments_handler():
1919

20-
with open('_comments.json', 'r') as file:
20+
with open('comments.json', 'r') as file:
2121
comments = json.loads(file.read())
2222

2323
if request.method == 'POST':
2424
comments.append(request.form.to_dict())
2525

26-
with open('_comments.json', 'w') as file:
26+
with open('comments.json', 'w') as file:
2727
file.write(json.dumps(comments, indent=4, separators=(',', ': ')))
2828

2929
return Response(json.dumps(comments), mimetype='application/json', headers={'Cache-Control': 'no-cache'})

server.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
server = WEBrick::HTTPServer.new :Port => 3000, :DocumentRoot => root
1818

1919
server.mount_proc '/comments.json' do |req, res|
20-
comments = JSON.parse(File.read('./_comments.json'))
20+
comments = JSON.parse(File.read('./comments.json'))
2121

2222
if req.request_method == 'POST'
2323
# Assume it's well formed
2424
comments << req.query
25-
File.write('./_comments.json', JSON.pretty_generate(comments, :indent => ' '))
25+
File.write('./comments.json', JSON.pretty_generate(comments, :indent => ' '))
2626
end
2727

2828
# always return json

0 commit comments

Comments
 (0)