Skip to content

Instantly share code, notes, and snippets.

@shaikh-shahid
Created January 7, 2019 17:06
Show Gist options
  • Save shaikh-shahid/0c6c2bc48f853a272d9f0ec23f663349 to your computer and use it in GitHub Desktop.
Save shaikh-shahid/0c6c2bc48f853a272d9f0ec23f663349 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();
router.get('/',function(req,res){
res.sendFile(path.join(__dirname+'/index.html'));
//__dirname : It will resolve to your project folder.
});
router.get('/about',function(req,res){
res.sendFile(path.join(__dirname+'/about.html'));
});
router.get('/sitemap',function(req,res){
res.sendFile(path.join(__dirname+'/sitemap.html'));
});
//add the router
app.use(express.static(__dirname + '/View'));
//Store all HTML files in view folder.
app.use(express.static(__dirname + '/Script'));
//Store all JS and CSS in Scripts folder.
app.use('/', router);
app.listen(process.env.port || 3000);
console.log('Running at Port 3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment