-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
69 lines (58 loc) · 1.74 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
const express = require('express'),
sgMail = require('@sendgrid/mail');
const app = express();
app.set("view engine", "ejs");
app.use(express.static(__dirname + '/public'));
// app.use(express.static(__dirname));
sgMail.setApiKey('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');
app.get("/", function(req, res){
res.render('index.ejs');
});
app.get("/services", function(req, res){
res.render('services.ejs');
});
app.get("/products", function(req, res){
res.render('products.ejs');
});
app.get("/aboutUs", function(req, res){
res.render('aboutUs.ejs');
});
app.get("/appointment", function(req, res){
var customer = req.query.customer;
// console.log(customer);
if(customer){
const msgToCustomer = {
to: customer.email,
from: 'tamanna_beauty_saloon@example.com',
subject: 'Appointment Booking',
text: 'Booking!',
html: 'Dear ' + customer.name + ' ,' +
'<br>' +
'Booking Successful! We will get in touch with you soon.'
};
const msgToCompany = {
to: 'v.anushka786@gmail.com',
from: 'tamanna_beauty_saloon@example.com',
subject: 'New appointment!',
text: 'Booking!',
html: '<h1>Appointment Booked!</h1>' +
'<br>' +
'<h2>Customer Details</h2>' +
'<br>' +
'<b>Customer Name: ' + customer.name +
'<br>' +
'<b>Customer Email: ' + customer.email +
'<br>' +
'<b>Contact Number: ' + customer.Number +
'<br>' +
'<b>Message: ' + customer.message
};
sgMail.send(msgToCustomer);
sgMail.send(msgToCompany);
}
res.render('appointment.ejs');
});
app.set('port', process.env.PORT || 3000);
app.listen(app.get('port'), function(){
console.log('Server listening on port', app.get('port'));
});