-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (56 loc) · 1.53 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const express = require("express");
const methodOverride = require('method-override');
const app = express();
const port = 8080;
const path = require("path");
const {v4: uuidv4} = require("uuid");
app.use(methodOverride('_method'));
app.use(express.urlencoded({extended: true}));
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "views"));
app.use(express.static(path.join(__dirname, "public")));
let users = [
{
id: uuidv4(),
username: "Pratham_Singh",
email: "[email protected]",
password: "1234",
content : "I love coding.",
},
{
id: uuidv4(),
username: "Abhishek shukla",
password: "1234",
content : "I love AI and anime.",
},{
id: uuidv4(),
username: "lavi moor",
password: "1234",
content : "I love data science.",
},
{
id: uuidv4(),
username: "admin",
password: "admin",
content: "Login As Admin",
}
]
app.get("/home", (req, res) =>{
res.render("index.ejs");
});
app.get("/home/login", (req, res) =>{
res.render("login.ejs");
});
app.get("/home/new", (req, res) =>{
res.render("register.ejs");
});
app.post("/home/", (req, res) =>{
let {username} = req.body;
res.render("loginsuccess.ejs", {username});
});
app.patch("/home/:username", (req, res) =>{
res.redirect("/home");
});
app.listen(port, () => {
console.log(`Listening start at port ${port}`);
});