-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
88 lines (72 loc) · 2.04 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
'use strict';
var http = require('http');
var express = require('express');
var aws = require('aws-sdk');
var path = require('path');
var mustache = require('mustache');
var fs = require('fs');
var parser = require('body-parser');
var app = express();
app.use(parser.urlencoded({
'extended': false,
'limit': 1024
}))
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.get('/about', function(req, res) {
res.sendFile(path.join(__dirname + '/about.html'));
});
app.get('/design', function(req, res) {
res.sendFile(path.join(__dirname + '/design.html'));
});
app.get('/space', function(req, res) {
res.sendFile(path.join(__dirname + '/space.html'));
});
app.get('/graphics', function(req, res) {
res.sendFile(path.join(__dirname + '/graphics.html'));
});
app.get('/craft', function(req, res) {
res.sendFile(path.join(__dirname + '/craft.html'));
});
app.get('/connect', function(req, res) {
res.sendFile(path.join(__dirname + '/connect.html'));
});
app.post('/sent', function(req, res) {
if (req.body.name !== undefined) {
if (req.body.email !== undefined) {
if (req.body.message !== undefined) {
aws.config.loadFromPath('aws-config.json');
var ses = new aws.SES();
ses.sendEmail({
'Source': '[email protected]',
'Destination': {
'ToAddresses': ['[email protected]']
},
'ReplyToAddresses': [req.body.email],
'Message': {
'Subject': {
'Data': req.body.subject
},
'Body': {
'Text': {
'Data': req.body.message
}
}
}
},
function(objectError, objectResult) {
console.log(objectError, objectResult);
});
}
}
}
res.status(200);
res.set({
'Content-Type': 'text/html'
});
res.write('thank you for your message');
res.end();
});
app.use('/', express.static(__dirname + '/'));
app.listen(8080);