Created
June 21, 2021 18:15
-
-
Save code08-ind/1c3a93ae4ab2f3f05cb7685d62b1b152 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 path = require('path'); | |
const express = require('express'); | |
const app = express(); | |
const port = 8000; | |
const localHost = '127.0.0.1'; | |
const staticPath = path.join(__dirname, '../public'); | |
const viewsPath = path.join(__dirname, '../views'); | |
app.set('view engine', 'ejs'); | |
app.use(express.static(staticPath)); | |
app.set('views', viewsPath); | |
app.get('/', (req, res) => { | |
res.render('Home', { title: "Home Page" }); | |
}); | |
app.get('/about', (req, res) => { | |
res.render('About', { title: "About Page" }); | |
}); | |
app.get('/*', (req, res) => { | |
res.render('Error', { title: "Error Page" }); | |
}); | |
app.listen(port, localHost, () => { | |
console.log(`Server Listening At Port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment