My Development Notes


Creating server and Dynamic Routing in Express for starters


Here’s the code syntax for dynamic routing and server creation in express JS :

const express = require("express");

const app = express();

app.get("/", (req, res) => {
  res.send("This is the homepage");
});

app.get("/about", (req, res) => {
  res.send("This is the about page");
});

app.listen(8000, () => {
  console.log("Server connected successfully");
});

Here’re the steps involved:

  • First require express
  • Create server on the port (localhost:8000)
  • define the routes on app.get

Leave a Reply

Your email address will not be published. Required fields are marked *