Introduction to Node.js Node.js is a runtime environment that allows us to run JavaScript outside the browser , mainly on the server. With Node.js, developers can use the same language—JavaScript—for both the front end and back end, which makes development simpler and quicker. Node.js is designed to handle many users at the same time without slowing down. It uses a non-blocking and event-driven model, meaning it does not wait for one task to finish before starting another. Instead, it responds to events as they happen. This makes Node.js perfect for applications that require quick responses and continuous communication. Applications of Node.js Real-time chat applications Video streaming platforms Online gaming servers REST APIs and backend services Single-page applications (SPAs) IoT (Internet of Things) applications Collaborative tools like shared editors or dashboards Architecture of Node.js Node.js follows a single-threaded, event-driven archi...
6 Experiment 6: ExpressJS – Routing, HTTP Methods, Middleware Write a program to define a route, Handling Routes, Route Parameters, Query Parameters and URL building. Below is a simple Express.js program that demonstrates: Defining routes Handling routes Route parameters Query parameters URL building 1. Install Express open command prompt mkdir abc cd abc npm init -y npm install express 2: Create app.js ( Simple program to start with) notepad app.js const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('Express routing working!'); }); app.listen(3000, () => { console.log('Server running on http://localhost:3000'); }); save and close. 3: Run Server node app.js Open browser: type link or url : http://localhost:3000 to see output ROUTING AND QUER...
Comments
Post a Comment