-
Notifications
You must be signed in to change notification settings - Fork 103
/
server.js
33 lines (24 loc) · 806 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
// This node server is not required, you can use index.html directly off
// the file system or a static host but you just have to use a question mark e.g.:
// http://localhost:8080/index.html?/r/gifs
var http = require('http');
var path = require('path');
var express = require('express');
var app = express();
app.set('port', process.env.PORT || 8080);
const publicFolder = [
'.well-known',
'css',
'images',
'js'
];
for (let name of publicFolder) {
app.use('/' + name, express.static(path.join(__dirname, name)));
}
var server = http.createServer(app);
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
server.listen(app.get('port'), function () {
console.log("Web server listening at: http://localhost:" + app.get('port'));
});