You are on page 1of 8

SIES College of Management Studies FYMCA (Revised), Sem I,

Roll No: 48

Assignment No. 1

(REPL, Modules, Request-Response )

1. Install and configure Node.js on your computers

Output:

2. Familiarisation with REPL


 Execute the following Commands : .help, .save, .load
Output:
PS E:\Node Code> node
Welcome to Node.js v18.13.0.
Type ".help" for more information.
> .help
.break Sometimes you get stuck, this gets you out
.clear Alias for .break

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1
.editor Enter editor mode
.exit Exit the REPL
.help Print this help message
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file

Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL


> console.log("hello");
hello
undefined
> .save hello.js
Session saved to: hello.js
> .load hello.js
console.log("hello");
hello
 Write a Node.js code to print your name on the console. Save the code
Output:

 Write a Node.js code to print all even numbers in between 22 and 42 inclusive of
both if they are even.

Code:
> for ( a = 22; a<=42; a++){

... if (a % 2 === 0){


..... console.log(a);
..... }
... }

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1

Output:

3. Write a Node.js code to solve the expression (x+y) 2 using functions. Execute in
REPL or Command prompt.
Code:
function s(x,y){
... return a=(x+y)**2;
... }
s(4,6);
Output:
100
4. Create a HTTP server to display your basic information Name, Age and Address on
the client.

Code:

Output:

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1

5. Create a module that will display the current date and time along with a concatenated
message, once the client tries to access the HTTP server.
Code:

Output:

6. Write a Node.js code to accept a query string from the user on the server through the
URL, and write it back to the client.

Code:

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1
Output:

7. Write a Node.Js code to pass specific input variables through the URL to the server
and the server should process then ad respond back.
Code:

Output:

8. Write a Node.js code to display your short Bio-Data (along with Photograph) saved in an
HTML file in response to the client’s access request to the server.

Code:

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1

var http = require('http');

var fs = require('fs');

http.createServer(function (req, res) {

fs.readFile('Biodata.html', function(err, data) {

res.writeHead(200, {'Content-Type': 'text/html'});

res.write(data);

return res.end();

});

}).listen(7777);

Output:

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24
SIES College of Management Studies FYMCA (Revised), Sem I,
Roll No: 48

Assignment No. 1

Subject: MCAWeb Technologies Academic Year First Half 2022_23


Batch:2022_24

You might also like