Express Js Node Js Example

https://expressjs.com/en/starter/installing.html

npm init
npm install express

Hello World Example

Create app.js file with following code.

const express = require("express");
const app = express();
const port = 3000;

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
});

We can use Express application generator also.

npx express-generator

npm start

localhost:3000

Basic Routing

error: