forked from espruino/EspruinoDocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
22 lines (19 loc) · 753 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* node.js script that creates a webserver to serve up the pages from the html directory */
var express = require('express');
var app = express();
app.all('/*', function(req, res, next) {
// The root page is part of the large site and so is not available
// locally. Instead we default to a given page to kick off.
if (req.url === '/') {
res.redirect('/Original.html');
return next();
} else if (!req.url.match(/.*\/?\./)) {
req.url += '.html';
}
console.log('returning: ' + req.url);
return express.static(__dirname + '/html')(req, res, next);
});
app.listen(process.env.PORT || 3040, function(app){
var port = this.address().port;
console.log('** EspruinoDocs - running on http://localhost:%s/Original **', port);
});