-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (25 loc) · 878 Bytes
/
app.js
File metadata and controls
34 lines (25 loc) · 878 Bytes
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
var express = require('express');
var http = require('http');
var https = require('https');
var path = require('path');
var fs = require('fs');
var app = express();
var port = process.env.PORT || 3000;
var securePort = process.env.SECURE_PORT || 3443
var sslOptions = {
key: fs.readFileSync('../cert/privkey.pem'),
cert: fs.readFileSync('../cert/cert.pem'),
};
app.use(express.logger('dev'));
app.disable('x-powered-by');
app.use(express.static(path.join(__dirname, 'public')));
app.set('port', process.env.PORT || 3000);
app.use(function (req, res) {
res.redirect("/");
});
http.createServer(app).listen(port, function(){
console.log('Express server listening on port ' + port);
});
https.createServer(sslOptions, app).listen(securePort, function(){
console.log('Secure Express server listening on port ' + securePort);
});