forked from mlsasrilanka/mschamps-23-web-app-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (24 loc) · 743 Bytes
/
index.js
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
30
31
const express = require("express");
const app = express();
const port = process.env.PORT || 3000;
app.use(express.static("public"));
app.get("/", (req, res) => {
res.sendFile(__dirname + "/public/index.html");
});
app.get("/home", (req, res) => {
res.sendFile(__dirname + "/public/home.html");
});
app.post("/submit", (req, res) => {
// Here you can add your code to process the form data
res.send("Form submitted successfully!");
});
app.get("/about", (req, res) => {
res.sendFile(__dirname + "/public/about.html");
});
// Custom 404 page
app.use((req, res, next) => {
res.status(404).sendFile(__dirname + "/public/404.html");
});
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
});