NodeJs step by step with windows

Hi, Welcome to nodeJs server side implementation of javascript.I will show you just a server setup and pring a helloworld message. I will give you a complete setup procedure.Then we can start...

1. At First you need to download  nodejs from their Site then install it.

2. Open your command prompt run "node --version"
   output like this  v0.10.29

3. Now goto your desktop or you desired Location and create a folder server_node or your desired name

4. Goto server_node folder(or your given folder).Create a file server.js

5. Copy and paste below code :P

var http = require('http');
var fs = require('fs');
var index = fs.readFileSync('index.html');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end(index);
}).listen(9000);

console.log("Server Running...");
*****************************

6. Now you need to create a file index.html in same folder.you copy and paste below code and cover it with html tag.

*********************index.html**************


Welcome to learn NodeJS.....

*****************************End**************************

7. Now run command prompt from project folder and run "node server.js"

8. Now you can see that "Server Running..." on your cmd.

9. Goto your browser and put url like this http://localhost:9000/

Now you can see a window like this...



Thanks.Happy coding with new technology... :P

Reactions

Post a Comment

0 Comments