Skip to content

Commit

Permalink
404:Page not found
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jul 1, 2022
1 parent 0546f33 commit fa0a057
Show file tree
Hide file tree
Showing 7 changed files with 15,947 additions and 722 deletions.
18 changes: 18 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Not a valid page</title>
</head>
<body>
<h1>Oops , This is not a valid page</h1>

<style>
h1{
color:red;
}
</style>
</body>
</html>
29 changes: 29 additions & 0 deletions 404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const express = require('express');
const path = require('path');

const port = 8000;
const app = express();
const publicPath = path.join(__dirname , 'public');

app.get('/index' , (req , res)=>{
res.sendFile(`${publicPath}/index.html`);
});

app.get('/about' , (_ , res) => {
res.sendFile(`${publicPath}/about.html`);
});

app.get('' , (_ , res) => {
res.sendFile(path.join(`${__dirname}/home.html`));
});

//rendering the 404 page
app.get('*' , (_ ,res) =>{
res.sendFile(path.join( `${__dirname }/404.html` ))
});

app.listen(port , (err) => {
if(!err){
console.log(`Server is running on the port:: ${port} `);
}
});
17 changes: 17 additions & 0 deletions home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
</head>
<body>
<h1>Home Page</h1>
<style>
h1{
color: yellowgreen;
}
</style>
</body>
</html>
Loading

0 comments on commit fa0a057

Please sign in to comment.