get express variable

  1. Use the express module to create an instance of the Express application:
const express = require('express');
const app = express();
  1. Define a route using the get method of the Express application instance:
app.get('/example', function(req, res) {
  // Route handling logic goes here
});
  1. Access parameters and query parameters from the request object (req):
app.get('/example/:param', function(req, res) {
  const paramValue = req.params.param; // Access parameter
  const queryParamValue = req.query.q; // Access query parameter
});
  1. Set response status and send a response:
app.get('/example', function(req, res) {
  res.status(200).send('Response sent');
});
  1. Start the Express application to listen for incoming requests on a specified port:
const PORT = 3000;
app.listen(PORT, function() {
  console.log(`Server is running on port ${PORT}`);
});