Skip to content

Commit

Permalink
Trying Nodejs
Browse files Browse the repository at this point in the history
Just for learning
  • Loading branch information
anandhost committed May 15, 2016
1 parent 0ad7c4e commit 44a133f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var express = require('express');
var app = express();
var fs = require('fs');

var user = {
"user4" : {
"name" : "mohit",
"password" : "pass4",
"profession" : "tchrr",
"id" : 4
}
9
};




app.get('/addUser', function (req, res){

fs.readFile( __dirname + "/" + "users.json", 'utf-8', function (err, data) {
data = JSON.parse(data);
data["user4"]= user["user4"];
console.log(data);
res.send(JSON.stringify(data));
});
})

var server = app.listen(8081, function () {

var host = server.address().address
var port = server.address().port

console.log("Listing at http://%s:%s", host, port)
})

0 comments on commit 44a133f

Please sign in to comment.