0% found this document useful (0 votes)
1 views2 pages

Node Js

Uploaded by

issearching8
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)
1 views2 pages

Node Js

Uploaded by

issearching8
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

Node.

js

[Link] is an open-source server environment that uses JavaScript on


the server. A [Link] application runs within a single process, without
generating a new thread for each request. [Link] includes
asynchronous I/O primitives as a part of its standard library, which
prevents JavaScript code from blocking, and, in general, libraries in
[Link] are developed using non-blocking paradigms. This makes
blocking behavior the exception instead of the rule.

Basic Example of [Link] Application


// Require http header
var http = require('http');

// Create server
[Link](function (req, res) {

// HTTP Status: 200 : OK


// Content Type: text/html
[Link](200, {'Content-Type': 'text/html'});

// Send the response body as "Hello World!"


[Link]('Hello World!');

}).listen(8080);

Output on [Link]
Hello world

Core Modules
[Link] includes several core modules for essential functionality. Some
commonly used ones are:
 fs (File System): Read/write files and directories.
var fs = require('fs');

 http: Create HTTP servers and clients.


var http = require('http');

 path: Manipulate file paths.

 events: Implement custom event handling.


var events = require('events');
var eventEmitter = new [Link]();
[Link]

[Link] is a minimal and flexible [Link] web application framework


that provides a list of features for building web and mobile applications
easily. It simplifies the development of server-side applications by
offering an easy-to-use API for routing, middleware, and HTTP utilities.

Example

// Import Express
const express = require('express');
const app = express();

// Define a route
[Link]('/', (req, res) => {
[Link]('Welcome to the [Link] Tutorial');
});

// Start the server


[Link](3000, () => {
[Link]('Server is running on [Link]
});
Output:

[Link] it will display

Welcome to the [Link] Tutorial

RESTful APIs: Develop robust APIs that adhere to the REST architectural
style, enabling communication with other applications and front-end
interfaces.

Postman is an API platform for building and using APIs. Postman


simplifies each step of the API lifecycle and streamlines collaboration so
you can create better APIs—faster.

You might also like