-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
148 lines (125 loc) · 3.71 KB
/
Copy pathserver.js
File metadata and controls
148 lines (125 loc) · 3.71 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//ec2-54-172-65-28.compute-1.amazonaws.com
var express = require('express'),
app = express(),
bodyParser = require('body-parser');
/*MONGODB AND MONGOOSEJS*/
//load the module
// var mongoose = require('mongoose/');
// mongoose.connect('mongodb://54.172.65.28:27017/mentorUS');
// var Schema = mongoose.Schema;
// var UserDetails = new Schema({
// firstName: String,
// lastName: String,
// eMail: String
// }, {
// });
app.use(bodyParser());
app.use(express.static(__dirname+'/public'));
/*MONGODB AND MONGOOSEJS*/
//load the module
// var mongoose = require('mongoose');
// //connect to the database
// mongoose.connect('mongodb://54.172.65.28:27017/mentorUS');
// var Schema = mongoose.Schema;
// //create schema and create module
// var mentorSchema = new Schema
// ({
// firstName: String,
// lastName: String,
// streetLine1: String,
// streetLine2: String,
// city: String,
// state: String,
// zipcode: String,
// Miles: String,
// age: String,
// educationLevel: String,
// career: String,
// sports: String,
// hobbies: String,
// familyEconomicBackground: String,
// socialMedia: String,
// eMail: String,
// economicBackgroundYouth: String,
// activitiesForMentee: String,
// servicesForMentee: String,
// maxMentees: String,
// availability: String
// });
// mentorSchema.methods.savelog = function(){
// var log = this.firstName;
// console.log('mentor \"'+log + '\" was saved');
// }
// var mentor = mongoose.model('mentor', mentorSchema);
/*ROUTES*/
app.get('/',function(req,res){
res.sendfile('index.html');
});
app.get('/signin',function(req,res){
res.sendfile('public/signin.html');
});
app.get('/mentor',function(req,res){
res.sendfile('public/mentor.html');
});
app.get('/parent',function(req,res){
res.sendfile('public/parent.html');
});
app.post('/signin',function(req,res){
console.log(req.body.name);
res.redirect('/profilehome');
});
app.get('/profilehome',function(req,res){
res.sendfile('public/profilehome.html');
});
app.post('/mentor', function(req,res){
// newMentor.save(function(err, entry) {
// if(err) {
// console.log(err);
// res.send(500, { error: err.toString()});
// }
// else {
// console.log('New product has been posted.');
// }
// console.log(newMentor);
res.redirect('/profilehome');
// });
});
/*LISTEN*/
app.listen(5000,function(){
console.log('listening on port 5000');
});
// var UserDetails = mongoose.model('userInfo', UserDetail);
/*this.addAddress = function (req, res) {
var newAddress = {
firstName: req.body.firstname,
lastName: req.body.lastname,
streetLine1: req.body.address,
streetLine2: req.body.address2,
city: req.body.city,
state: req.body.state,
zipcode: req.body.zip,
Miles: rec.body.miles,
age: req.body.age,
educationLevel: req.body.education,
career: req.body.career,
sports: req.body.sports,
hobbies: req.body.hobbies,
familyEconomicBackground: req.body.familyEconmicBackground,
socialMedia: req.body.social,
eMail: req.body.email,
economicBackgroundYouth: rec.body.ecoYouth,
activitiesForMentee: rec.body.activites,
servicesForMentee: rec.body.services,
maxMentees: rec.body.max_mentees,
availability: rec.body.availability
}
mentor.update({username: req.session.user}, { $push : {
address: newAddress
}}, {upsert: true}, function ( err ) {
if(err){
console.log(err);
}else{
console.log("Successfully added");
}
})
}*/