Created
April 1, 2021 21:20
-
-
Save elpuas/40a2328416dba3c2f93956ff541ceea9 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() | |
// 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