Last active
April 6, 2021 21:40
-
-
Save elpuas/ec6b299646a099fca58846ab10b8efe0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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') | |
// Add the Public Folder for Assets | |
app.use(express.static('public')) | |
app.listen( 3000, () => { | |
console.log('App listening on port 3000') | |
}) | |
// App Routes | |
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