Skip to content

Instantly share code, notes, and snippets.

@elpuas
Created April 1, 2021 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elpuas/40a2328416dba3c2f93956ff541ceea9 to your computer and use it in GitHub Desktop.
Save elpuas/40a2328416dba3c2f93956ff541ceea9 to your computer and use it in GitHub Desktop.
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