-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
27 lines (25 loc) · 1.02 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
/* Copyright Temasys Communications, 2014 */
var connect = require('connect');
var fs = require('fs');
var http = require('http');
var https = require('https');
var app = connect();
app.use(connect.static(__dirname));
console.log("HTTP server instance running @ 8081");
http.createServer(app).listen(process.env.PORT || 8081);
fs.stat('certificates/server.key', function(err, stat) {
if(err == null) {
https.createServer({
key: fs.readFileSync('certificates/server.key'),
cert: fs.readFileSync('certificates/server.crt')
}, app).listen(8082);
console.warn("\nNOTE: Running HTTP server has been removed as " +
"getUserMedia() has been deprecated for HTTP on Chrome 42 and above. " +
"Please run demo on HTTPS as recommended\n\n-\n");
console.log("HTTPS server instance running @ 8082");
} else {
console.warn("HTTPS server instance failed to start as" +
+ " certificate failed to load\n" +
"Error (for certificates/server.key): " + err.code);
}
});