-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
78 lines (60 loc) · 1.56 KB
/
app.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
67
68
69
70
71
72
73
74
75
76
77
78
const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");
const mongoose = require("mongoose");
const app = express();
// mongoose.connect("mongodb://localhost:27017/mainDB", {useNewUrlParser: true, useUnifiedTopology: true});
// const userSchema = {
// email: String,
// password: String
// };
//
// const User = new mongoose.model("User", userSchema);
app.use(express.static("public"));
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({extended: true}));
//
// const userSchema = {
// fullname: String,
// age: String,
// email: String,
// user_name: String
// };
// const User = mongoose.model("User", userSchema);
app.get("/", function(req, res){
res.render("home");
});
app.get("/login", function(req, res){
res.render("login");
});
app.get("/register", function(req, res){
res.render("register");
});
app.get("/app", function(req, res){
res.render("app");
});
app.post("/register", function(req, res){
// const user = new User ({
// fullname: req.body.fullname,
// age: req.body.age,
// email: req.body.email,
// user_name: req.body.userName
// });
user.save();
res.redirect("/user");
});
// app.get("/users/:userName", function(req, res){
//
// res.render("user", {
// fullname: user.fullname,
// age: user.age,
// email: user.email,
// user_name: user.user_name
// });
// });
app.get("/user", function(req, res){
res.render("user");
});
app.listen(3000, function() {
console.log("Server started on port 3000.")
});