0% found this document useful (0 votes)
14 views19 pages

PS Practical 1 To 4

The document outlines the curriculum for the Programming Skills Lab II (CS410) at P. R. Pote Patil College of Engineering & Management, focusing on MongoDB and NodeJS for the academic year 2024-25. It includes a certification template for students, a list of practical experiments, and assessment criteria for evaluating student performance. Each practical aims to teach various aspects of NodeJS and MongoDB, including environment setup, HTTP module usage, file system operations, and URL module implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views19 pages

PS Practical 1 To 4

The document outlines the curriculum for the Programming Skills Lab II (CS410) at P. R. Pote Patil College of Engineering & Management, focusing on MongoDB and NodeJS for the academic year 2024-25. It includes a certification template for students, a list of practical experiments, and assessment criteria for evaluating student performance. Each practical aims to teach various aspects of NodeJS and MongoDB, including environment setup, HTTP module usage, file system operations, and URL module implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

P. R.

POTE PATIL

College of Engineering & Management, Amravati.

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Year: 2024-25 Semester: IV

Course: Programming Skills Lab II(MongoDB & NodeJS)


(CS410)
Programming skill Lab II (CS410)

Computer Science and Engineering Department


Programming skill Lab II (CS410)

P. R. POTE PATIL
COLLEGE OF ENGINEERING & MANAGEMENT, AMRAVATI.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Certificate

This is to certify that Mr./ Ms …………………………………………...

of ….... Semester of Bachelor of Technology in Computer

Science and Engineering of P. R. Pote Patil College of

Engineering & Management, Amravati, has completed the

term work satisfactory of course …………………. for the

academic year 20 - 20 as prescribed in the curriculum.

Date………………… Roll No……………………

Subject Teacher Head of the

Computer Science and Engineering Department


Programming skill Lab II (CS410)

Department
LIST OF (PRACTICALS / EXPERIMENTS) & PROGRESSIVE ASSESSMENT FOR TERM WORK

Academic Year :2024-25 Course: Programming Skill Lab II


Course Code: CS410 Semester: IV

Name of Faculty: ______________________________

Name of Student: ______________________________

Roll No _____________________
Date of Date of
Title of the Sign of
SN. Performanc Submissio
Practical / Experiment Teacher
e n
Explore the concept of NodeJS & Setup
1 its environment for development. Run
a Node Js program to print ‘Hello world’
Accomplish the concept of HTTP
2
module & Run a program in NodeJS.
Perform various operations like create,
3 update, rename & delete using file
system Module in NodeJS
Execute the concept of URL Module .
Run a program to split a web address
4
into readable parts using url.parse()
method
Implement NodeJS event module . Run
5 a NodeJS program using EventEmitter
class
Explore the database MongoDB &
setup its environment for
development. Create a MongoDB
6
document using fields numbers,
strings, boolean, arrays, or even
nested documents.
Develop a database & collection using
7
NodeJS & MongoDB.
Apply Insert operation in MongoDB to
8 insert a document into collection &
run a program into NodeJS.
Implement delete operation in
9 MongoDB to delete a record from
collection & run a program in NodeJS.
Compile a NodeJS program to update
1
the record in collection in MongoDB
0
using UpdateOne() command.

Computer Science and Engineering Department


Programming skill Lab II (CS410)

Signature of Faculty

Computer Science and Engineering Department


Programming skill Lab II (CS410)

Assessment

Marks Rubrics: 25 = a (07) + b (04) + c (04) + d (04) + e (03) + f (03)


a: Handle equipment/ tools/ commands correctly & safely/ Logic Formation
b: Integrate system & measure parameters correctly or Debugging Ability
c: Completed experiment as per schedule
d: Obtain correct results, Interpret results
e: Draw conclusion
f: Answer practical related questions & submit the write up of experiment
on time

Title of the (a) (b) (c) (d) (e) (f) Total


S.N.
Practical / Experiment 07 04 04 04 03 03 25 Marks
Explore the concept of NodeJS & Setup its
01 environment for development. Run a Node Js
program to print ‘Hello world’
Accomplish the concept of HTTP module & Run
02
a program in NodeJS.
Perform various operations like create, update,
03 rename & delete using file system Module in
NodeJS
Execute the concept of URL Module . Run a
04 program to split a web address into readable
parts using url.parse() method
Implement NodeJS event module . Run a
05
NodeJS program using EventEmitter class
Explore the database MongoDB & setup its
environment for development. Create a
06 MongoDB document using fields numbers,
strings, boolean, arrays, or even nested
documents.
Develop a database & collection using NodeJS &
07
MongoDB.
Apply Insert operation in MongoDB to insert a
08 document into collection & run a program into
NodeJS.
Implement delete operation in MongoDB to
09 delete a record from collection & run a program
in NodeJS.
Compile a NodeJS program to update the
10 record in collection in MongoDB using
UpdateOne() command.

Computer Science and Engineering Department


Programming skill Lab II (CS410)

PRACTICAL NO. 1

AIM: Explore the concept of NodeJS & Setup its environment for development.
Run a Node Js program to print ‘Hello world’

OBJECTIVES: (a) To introduce Node.js


(b) To setup Node.js environment and print hello world.

SOFTWARE: Node JS, Command Prompt

THEORY:

Introduction to Node.js-
Node.js is a cross-platform environment and library for running JavaScript
applications which is used to create networking and server-side applications.
It is used for creating server-side and networking web applications. It is open
source and free to use. It can be downloaded from this link https://nodejs.org/en/
Node.js is mostly used to run real-time server applications.

1.What can Node.js do?


 Node.js can generate dynamic page content.
 Node.js can create, open, read, write, delete and close the files on server.
 Node.js is a platform built on Chrome's JavaScript runtime for easily
building fast and scalable network applications.
 Node.js uses an event-driven, non-blocking I/O model that makes it
lightweight and efficient, perfect for data-intensive real-time applications
that run across distributed devices.
 Node.js also provides a rich library of various JavaScript modules to
simplify the development of web applications.
What is Node.js file?

 Node.js files contain the task that will be executed on certain event.
 A typical event is someone trying to access to a part of server.
 Node.js files must be initiated on the server before having any effect.
 Node.js files have extension “ .js”
Node.js uses asynchronous programming. A common task for a web server can
be to open a files on the server & return the content to the client.

Lets see how PHP or ASP handles the file request.


 Send the task to the computer’s file system.
 Waits while the file system opens and read the file.
 Returns the contents to the client
 Ready to handle the next request.
Lets see how the Node.js handle the file request.
 Send the task to the computer file system .
 Ready to handle the next request

Computer Science and Engineering Department


Programming skill Lab II (CS410)

 When the file system has opened and read the file , the server returns
the content to the file .
 Node.js eliminates the waiting and simply continues with the next
request.
 Node.js runs single threaded , non-blocking asynchronous programing
which is very memory efficient .
Installation
Download Node.js from official Node.js website .https://nodejs.org

To install and setup an environment for Node.js, you need the following two
software’s available on your computer:

1. Text Editor.
2. Node.js Binary installable
3. Text Editor:
4. 1.The text editor is used to type your program. For example: Notepad is
used in Windows, vim or vi can be used on Windows as well as Linux or
UNIX. The name and version of the text editor can be different from
operating system to operating system.
5. 2.The files created with text editor are called source files and contain
program source code. The source files for Node.js programs are typically
named with the extension ".js".

The Node.js Runtime:

The source code written in source file is simply JavaScript. It is interpreted and
executed by the Node.js interpreter.

How to download Node.js:

You can download the latest version of Node.js installable archive file
from https://nodejs.org/en/

Here, you deploy the installation of node-v4.4.2 LTS recommended for most
users.

Computer Science and Engineering Department


Programming skill Lab II (CS410)

Accept the terms of license agreement.

Choose the location where you want to install.

Computer Science and Engineering Department


Programming skill Lab II (CS410)

Ready to install:

Computer Science and Engineering Department


Programming skill Lab II (CS410)

CONCLUSION:

ASSESSMENT SCHEME:

Process Related Product Related Total Signature of


Skills Skills (25-M) Faculty
(15-M) (10-M)

PRACTICAL NO. 2

Computer Science and Engineering Department


Programming skill Lab II (CS410)

AIM: Accomplish the concept of HTTP module & Run a program in NodeJS.

OBJECTIVES: (a) To understand http module


(b) To create a simple web server using node.js

SOFTWARE: Node Js, Command Prompt

THEORY: What is module in Node.js? Modules to be the same as Javascript


libraries . A set of function you want to include in your application.

Built-In modules
Node.js has set of built in modules which you can use without any further
installation.

Modules Description
Assert Provides a set of assertion task
Buffer To handle the binary data
Child-process To run a child process
Cluster To split a single node process into multiple processes.
Crypto To handle open SSL cryptographic function
Dgram Provides implementation of UDP diagram socket
Dns To do DNS lookups and name resolution functions
Domain Deprecated. To handle unhandled errors.
Events To handle the events
Fs To handle the file system
http To make node.js act as a http server
https To make node.js act as a https server
Net To create the servers & clients
Os Provide info about the operation system
Path To handle the file paths
Punycode Deprecated. A character encoding scheme.
Query string To handle URL query string
Readline To handle readable strings one at a time.
Stream To handle the streaming data
String decoder To decode buffer objects into strings
Timers To execute the function after the given number of ms
Tls To implement TLS & SSL protocol
Tty Provides classes use by text terminal
url To parse url string
Util To access the utility functions
V8 To access the information about javascript engine(v8)
Vm To compile javascript code into the virtual machine
Zlib To compress or decompress the file

Node.js has a built-in module called HTTP, which allows Node.js to transfer data
over the Hypertext Transfer Protocol (HTTP). The HTTP module can create an
HTTP server that listens to server ports and gives a response back to the client.

Computer Science and Engineering Department


Programming skill Lab II (CS410)

There are variety of modules such as “http” & “request” module which helps in
processing the server related requests in the web server space.
We will have a look how we can create a basic web server application using
Node.js

To implement web server in Node.js

Program Input:

Program
Output:

CONCLUSION:

ASSESSMENT SCHEME:

Process Related Product Related Total Signature of


Skills Skills (25-M) Faculty
(15-M) (10-M)

Computer Science and Engineering Department


Programming skill Lab II (CS410)

PRACTICAL NO. 3

AIM: To study and implement Node.js File system module to read, write, create,
update, delete and rename the file.

OBJECTIVES: (a) To understand the file system module.


(b) To implement the file system module.

SOFTWARE: Node Js, Command Prompt

THEORY: The Node.js file system module allows you to work with the file
system on your computer. To include the file system module , use the require()
method.
Var fs=require(‘fs’);
Common use for the file system module:
 Read files
 Create files
 Update files
 Delete files
 Rename files

Program code:

1. Read file:

Computer Science and Engineering Department


Programming skill Lab II (CS410)

2. Append file:

3. Write file:

4. Delete file:
a. In the below code, we are trying to delete a file that does not exist.

b. In the below code, we are trying to delete an existing file.

Computer Science and Engineering Department


Programming skill Lab II (CS410)

5. Rename a file:

Program Output:
1. Read file:

2. Append file:

3. Write file:

Computer Science and Engineering Department


Programming skill Lab II (CS410)

4. Delete file:
a. When trying to delete a non-existing file, the following error is
occurred:
b.

Deleting an existing file:

5. Rename file:

CONCLUSION:

ASSESSMENT SCHEME:

Process Related Product Related Total Signature of


Skills Skills (25-M) Faculty
(15-M) (10-M)

Computer Science and Engineering Department


Programming skill Lab II (CS410)

PRACTICAL NO. 4

AIM: Execute the concept of URL Module . Run a program to split a web address
into readable parts using url.parse() method

OBJECTIVES: (a) To understand the URL module of the Node.js


(b)To write a program to open a requested file & returns the
contents of
file to client.

SOFTWARE: Node Js, Command Prompt

THEORY: The URL module splits up a web address into readable parts.

To include the URL module, use the require() method:

Program Input:

Program Output:

Computer Science and Engineering Department


Programming skill Lab II (CS410)

CONCLUSION:

ASSESSMENT SCHEME:

Process Related Product Related Total Signature of


Skills Skills (25-M) Faculty
(15-M) (10-M)

Computer Science and Engineering Department

You might also like