-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
60 lines (45 loc) · 1.43 KB
/
index.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
let express = require('express');
let app = express();
let handlebars = require('express-handlebars').create({defaultLayout:'main'});
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
let bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.set('port', 4372);
app.get('/',function(req,res){
res.render('index', {layout: null});
});
app.get('/about',function(req,res){
res.render('about', {layout: null});
});
app.get('/connect',function(req,res) {
res.render('connect', {layout: null});
});
app.post('/connect',function(req,res) {
req.body.name()
req.body.email()
res.render("thankyou", {layout: null})
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/gallery',function(req,res) {
res.render('gallery', {layout: null});
});
app.get('/thankyou',function(req,res) {
res.render('thankyou', {layout: null});
});
app.use(function(req,res){
res.type('text/plain');
res.status(404);
res.render('404 - Not Found', {layout: null});
});
app.use(function(err, req, res, next){
console.error(err.stack);
res.type('plain/text');
res.status(500);
res.render('500 - Server Error', {layout: null});
});
app.listen(app.get('port'), function(){
console.log('Express started on http://localhost:' + app.get('port') + '; press Ctrl-C to terminate.');
});