-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
84 lines (64 loc) · 2.09 KB
/
app.js
File metadata and controls
84 lines (64 loc) · 2.09 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
/**
*
* expresspugbootstrap
* -----------------------------------------------
* An Node.JS template with
* — Express
* — Pug (formerly Jade)
* — Bootstrap (pug-bootstrap)
*
* https://github.com/JANQLIANGTSAI/expresspugbootstrap
* Copyright 2016-present, Max J. Tsai
* All rights reserved.
* -----------------------------------------------
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/** Express **/
var express = require('express');
/** Core **/
var path = require('path');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var multer = require('multer');
/** optionals **/
var favicon = require('serve-favicon');
/** -------------- INIT ------------------ **/
var app = express();
/** -------------------------------------- **/
/** settings **/
// port
app.set('port', 8080);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
/** favicon **/
app.use(favicon(__dirname + '/public/favicon.ico'));
/** Static Pages **/
app.use(express.static(path.join(__dirname, 'public')));
/** view engine **/
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
// mapping css folder
app.use('/css/bootstrap', express.static(path.join(__dirname, 'node_modules/pug-bootstrap/css')));
/** cookies **/
app.use(cookieParser());
/** body parsing **/
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// for multipart: var upload = multer();
/** -------------------------------------- **/
app.get('/hello', function (req, res) {
res.send('Hello World');
})
/** routing **/
var indexRoute = require('./routes/index');
app.use('/', indexRoute);
var server = app.listen(app.get('port'), function () {
var host = server.address().address
var port = server.address().port
console.log(`Express Server listening at http://${host}:${port}`);
})