// Server.js
var http = require('http');
var path = require('path');
var fs = require('fs');
http.createServer(function (request, response) {
    console.log('request starting...');
    var filePath = '.' + request.url;
    if (filePath == './')
        filePath = './index.html';
    path.exists(filePath, function(exists) {
        if (exists) {
            fs.readFile(filePath, function(error, content) {
                if (error) {
                    response.writeHead(500);
                    response.end();
                }
                else {
                    response.writeHead(200, { 'Content-Type': 'text/html' });
                    response.end(content, 'utf-8');
                }
            });
        }
        else {
            response.writeHead(404);
            response.end();
        }
    });
}).listen(8125);
console.log('Server running at http://127.0.0.1:8125/');
// index.html
<html>
    <head>
        <title>Rockin' Page</title>
        <link type="text/css" rel="stylesheet" href="style.css" />
        <script type="text/javascript" src="jquery-1.7.1.min.js"></script>   
        </head>
    <body>
        <p>This is a page. For realz, yo.</p>
    </body>
    <script type="text/javascript">
        $(document).ready(function() {
            alert('happenin');
        });
    </script>
</html>
I am able to run my static page, but i have couple of questions down the line.
- What do i do next? i mean what to develop and what to learn? i am confused.. what is the difference i am doing with my current webserver.
- Is node.js just an replacement of my Apache Webserver.
- Can anyone clearly explain me the main purpose of nodejs
 
     
     
     
    