-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (34 loc) · 1.04 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
/**
* Created by xu on 2016/8/29.
*/
var express = require('express');
var fs = require('fs');
var http = require('http');
var https = require('https');
var path = require('path');
var bodyParser = require('body-parser');
var port = process.env.PORT || 4000;
var open = require('open');
var options = {
key : fs.readFileSync('./cert/privatekey.pem'),
cert : fs.readFileSync('./cert/certificate.pem')
}
var app = express();
app.use(bodyParser());
app.use(express.static(path.join(__dirname, 'public')));
app.set('views', __dirname + '/views');
app.engine('html', require('ejs').__express);
app.set('view engine', 'html');
app.get('/', function(req, res){
res.render('vue');
});
httpsSer = https.createServer(options, app).listen(port, '', function(err){
if(err) return;
console.log('Server started, listening on port:' + port)
open('https://localhost:' + port + '/')
});
var httpSer = http.createServer(app).listen('4001', '', function(err){
if(err) return;
console.log('Server started, listening on port:4001')
open('http://localhost:4001/')
});