-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstProgram.js
More file actions
33 lines (20 loc) · 1.08 KB
/
Copy pathfirstProgram.js
File metadata and controls
33 lines (20 loc) · 1.08 KB
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
//DISPLAY HELLO WORLD ON WEB BROWSER
//require function ---- reads a JavaScript file, executes the file, and
//then proceeds to return an object. Using this object, one can then use the various
//functionalities available in the module called by the require function. So in our case,
//since we want to use the functionality of http and we are using the
//require(http) command.
var http = require('http');
//In this 2nd line of code, we are creating a server application which is based
//on a simple function. This function is called, whenever a request is made to
//our server application.
http.createServer(function (req, res)
{
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('hello to the outerspace!'); // when request is received, we ask
//for Hello World
}).listen(8080); // make our server application listen to client requests
// on port no 8080 (specify any available port over here
// what is a port?
// INSTALLED EXPRESS using npm install express in terminal
// use "require" from now on to use a module in a Node app