Created
January 7, 2019 17:06
-
-
Save shaikh-shahid/0c6c2bc48f853a272d9f0ec23f663349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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