how to install express js and wht is express js

 to run on port we have to use some middle wares or frameworks

below listed are middlewares

express js

koa

hapi


what is express js

it is a framework 

it is opensource

we can devbelop web applicatiosn and apis

it is scalable

fast app development

it is user frendly and customizable

we can intergrate easily third party services and middlewares

package.json

whenerver package is isntalled it will show in dependecies-> package.json

ito install an y applications, it will be possible by commands

npm install express


"dependencies": {
"express": "^4.18.2"
}


write belw code in second.js file

const express= require('express');
const app = express();
const PORT=3000;
app.listen(PORT,() =>
{
console.log("server on::"+PORT)
}
)

 


console.log(req) - it shows total object

if (req.url ==='/'){

res.end('welcome')

}

default output

res.end('oops')

\then call in terminal by node second.js

based on code it wil run in this url

http://localhost:3000/

what ever u required- u have to import

after that u have to export if u wanna use in some other file

as per code it will print in condole log







No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...