-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
40 lines (26 loc) · 830 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var express = require("express");
var bodyParser = require('body-parser');
var application = express();
application.use(bodyParser());
var comments = [
{
'user' : 'John',
'text' : 'This is rude comment'
},
{
'user' : 'James',
'text' : 'This is nice comment'
}
];
application.use(express.static("client"));
application.listen(process.env.PORT);
application.get('/comments', function(request , response){
var content = JSON.stringify(comments);
response.send(content);
});
application.post('/addComment' , function(request , response){
var comment = {} ;
comment.text = request.body['text'];
comment.user = request.body['user'];
comments.push(comment);
});