-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
111 lines (97 loc) · 2.29 KB
/
server.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const express = require("express");
const mongoose = require("mongoose");
const path = require("path");
const port = 3019;
const app = express();
app.use(express.static(__dirname));
app.use(express.urlencoded({ extended: true }));
mongoose.connect("mongodb://127.0.0.1:27017/coders");
const db = mongoose.connection;
db.once("open", () => {
console.log("Mongodb connection successful");
});
const userSchema = new mongoose.Schema({
email: String,
name: String,
myfile: String,
proname: String,
url: String,
appl: String,
num: Number,
git: String,
prdesc: String,
student: String,
pro1: String,
pro1pro: String,
pro2: String,
pro2pro: String,
});
const Users = mongoose.model("data", userSchema);
app.post("/mentor", async (req, res) => {
const { email, name, myfile, proname, prodesc, url, appl } = req.body;
const mentor = new Users({
email,
name,
myfile,
proname,
prodesc,
url,
appl,
});
await mentor.save();
console.log(mentor);
res.sendFile(path.join(__dirname, "index.html"));
});
app.post("/mentee", async (req, res) => {
const {
email,
name,
myfile,
num,
git,
student,
pro1,
pro1pro,
pro2,
pro2pro,
} = req.body;
const mentee = new Users({
email,
name,
myfile,
num,
git,
student,
pro1,
pro1pro,
pro2,
pro2pro,
});
await mentee.save();
console.log(mentee);
res.sendFile(path.join(__dirname, "index.html"));
});
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
app.get("/mentee.html", (req, res) => {
res.sendFile(path.join(__dirname, "mentee.html"));
});
app.get("/mentor.html", (req, res) => {
res.sendFile(path.join(__dirname, "mentor.html"));
});
app.get("/index.html", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
app.get("/about.html", (req, res) => {
res.sendFile(path.join(__dirname, "about.html"));
});
app.get("/projects.html", (req, res) => {
res.sendFile(path.join(__dirname, "projects.html"));
});
app.get("/guidelines.html", (req, res) => {
res.sendFile(path.join(__dirname, "guidelines.html"));
});
app.listen(port, () => {
console.log("server started");
});