-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpress.js
42 lines (33 loc) · 1.15 KB
/
express.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
32
33
34
35
36
37
38
39
40
41
42
const express = require("express");
const app = express();
const PORT = process.env.PORT || 5000;
const path = require("path");
app.use("/", express.static(path.join(__dirname, "web/build")));
app.get("/api/v1/tanveer", (req, res) =>
res.send(
"<h1>Welcome to get request of Tanveer hey you know on / there is todo app</h1>"
)
);
app.post("/api/v1/tanveer", (req, res) =>
res.send("<h1>Create Post Successfully</h1>")
);
app.put("/api/v1/tanveer", (req, res) =>
res.send("<h1>Post has been Updated</h1>")
);
app.delete("/api/v1/tanveer", (req, res) =>
res.send("<h1>Post has been Deleted</h1>")
);
app.get("/**", (req, res) =>
res.send("<h1><center>Error: 404 <br/>Page Not Found</center></h1>")
);
// app.use((req, res) => res.send("<h1><center>Page Not Found</center></h1>"));
// app.use((req, res, next) => res.redirect("/404"));
// app.use((req, res) =>
// res.sendFile(path.join(__dirname, "web/build/index.html"))
// );
// app.use("/**", (req, res) =>
// res.sendFile(path.join(__dirname, "web/build/index.html"))
// );
app.listen(PORT, () =>
console.log(`Example app listening on port port! http://localhost:${PORT}`)
);