-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavbar-app-express.js
More file actions
29 lines (24 loc) · 851 Bytes
/
Copy pathnavbar-app-express.js
File metadata and controls
29 lines (24 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const path = require("path");
const express = require("express");
const app = express();
const hostName = "127.0.0.8";
const port = 4040;
app.use(express.static('./navbar-app/resources/javascript'));
app.use(express.static('./navbar-app/resources/css'));
app.use(express.static('./navbar-app/resources/images'));
app.get("/", (req, res) => {
res.sendFile(path.resolve(__dirname, `./navbar-app/index.html`));
});
app.all("*", (req, res) => {
res.send(`
<div style = "display: grid; justify-content: center; align-items:center; height:100vh;">
<div style="text-align: center;">
<h1>This is the wrong page</h1>
<a href="/">Go Home</a>
</div>
</div>
`);
});
app.listen(port, hostName, () => {
console.log(`Server is running of http://${hostName}:${port}/`);
});