express load a page

Solutions on MaxInterview for express load a page by the best coders in the world

showing results for - "express load a page"
Ambrine
01 Jan 2020
1const express = require('express');
2const app = express();
3const path = require('path');
4const router = express.Router();
5
6router.get('/',function(req,res){
7  res.sendFile(path.join(__dirname, '/index.html'));
8  //__dirname : It will resolve to your project folder.
9});
10
11// To go back a folder from __dirname
12router.get('/about',function(req,res){
13  res.sendFile(path.join(__dirname, '../somefolder/about.html'));
14});