Home > Programming > Creating a HTTP Web Server Using NodeJs

Creating a HTTP Web Server Using NodeJs

Here I am gonna show you how to create a HTTP Web Server .Node.js is an evented system,.

To create an application using NodeJs you simply make sure that you have installed NodeJs in your system .

Write this code on your textfile

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

To run the server, put the code into a file app.js and execute it with thenode program:

Go to command Prompt

go to NodeJs Directory and Type

C:\ NodeJs>node app.js
Server running at http://127.0.0.1:1337/

Then go to your browser and type above address🙂🙂 Enjoy

Categories: Programming
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: