Skip to content

Instantly share code, notes, and snippets.

@code08-ind
Created June 20, 2021 19:08
Show Gist options
  • Save code08-ind/c1e696b63c8370a4f3a2d30abe43ed42 to your computer and use it in GitHub Desktop.
Save code08-ind/c1e696b63c8370a4f3a2d30abe43ed42 to your computer and use it in GitHub Desktop.
const path = require('path');
const express = require('express');
const hbs = require('hbs');
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.use(express.static(staticPath));
app.set('view engine', 'hbs');
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