-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathserver.js
34 lines (30 loc) · 832 Bytes
/
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
28
29
30
31
32
33
34
(function () {
'use strict';
var connect = require('connect'),
fs = require('fs'),
port = 2000,
options = {
key: fs.readFileSync('privatekey.pem').toString(),
cert: fs.readFileSync('certificate.pem').toString()
};
function route(app) {
app.get('/', function (req, res) {
/*
res.writeHead(401, {'WWW-Authenticate': 'Basic realm="Secure Area"'});
res.end("I'm sorry, but your credentials were not acceptabe. Please make a sacrifice to the gods and try again");
*/
res.writeHead(200);
res.end("Welcome to my domain");
});
}
connect(options,
connect.basicAuth(function (user, pass) {
console.log('User:', user);
console.log('Password:', pass);
return true;
}),
connect.router(route)
).listen(port, function () {
console.log('Server listening on port ' + port);
});
}());