PS Practical 1 To 4
PS Practical 1 To 4
POTE PATIL
P. R. POTE PATIL
COLLEGE OF ENGINEERING & MANAGEMENT, AMRAVATI.
Certificate
Department
LIST OF (PRACTICALS / EXPERIMENTS) & PROGRESSIVE ASSESSMENT FOR TERM WORK
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.
Signature of Faculty
Assessment
PRACTICAL NO. 1
AIM: Explore the concept of NodeJS & Setup its environment for development.
Run a Node Js program to print ‘Hello world’
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.
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.
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 source code written in source file is simply JavaScript. It is interpreted and
executed by the Node.js interpreter.
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.
Ready to install:
CONCLUSION:
ASSESSMENT SCHEME:
PRACTICAL NO. 2
AIM: Accomplish the concept of HTTP module & Run a program in NodeJS.
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.
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
Program Input:
Program
Output:
CONCLUSION:
ASSESSMENT SCHEME:
PRACTICAL NO. 3
AIM: To study and implement Node.js File system module to read, write, create,
update, delete and rename the file.
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:
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.
5. Rename a file:
Program Output:
1. Read file:
2. Append file:
3. Write file:
4. Delete file:
a. When trying to delete a non-existing file, the following error is
occurred:
b.
5. Rename file:
CONCLUSION:
ASSESSMENT SCHEME:
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
THEORY: The URL module splits up a web address into readable parts.
Program Input:
Program Output:
CONCLUSION:
ASSESSMENT SCHEME: