Skip to content

Instantly share code, notes, and snippets.

@elpuas
Created Apr 1, 2021
Embed
What would you like to do?
const express = require('express')
const app = express()
// path is a built in module in Node
// It Helps get the specific path to the files
const path = require('path')
app.listen( 3000, () => {
console.log('App listening on port 3000')
})
app.get('/', ( req, res ) => {
res.sendFile( path.resolve( __dirname, 'index.html') )
})
app.get('/about', ( req, res ) => {
res.sendFile( path.resolve( __dirname, 'about.html') )
})
app.get('/contact', ( req, res ) => {
res.sendFile( path.resolve( __dirname, 'contact.html') )
})
app.get('*', (req, res) => {
res.sendFile( path.resolve(__dirname, '404.html'))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment