forked from heroku/node-js-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.js
More file actions
34 lines (26 loc) · 664 Bytes
/
web.js
File metadata and controls
34 lines (26 loc) · 664 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 fs = require('fs');
var app = express.createServer(express.logger());
var indexPage;
var indexLoadFail = function(e) {
console.log('Problem loading index.html -- "' + e + '"');
process.exit(1);
};
var loadIndex = function() {
try {
indexPage = fs.readFileSync('index.html').toString();
} catch(e) {
indexLoadFail(e);
}
};
app.get('/', function(request, response) {
if(indexPage === undefined) {
indexLoadFail('EXCEPTION NOT CAUGHT');
}
response.send(indexPage);
});
var port = process.env.PORT || 8085;
app.listen(port, function() {
loadIndex();
console.log("Listening on " + port);
});