-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (27 loc) · 700 Bytes
/
server.js
File metadata and controls
34 lines (27 loc) · 700 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
const path = require('path');
const http = require('http');
const express = require('express');
module.exports = () => {
const app = express();
const server = http.Server(app);
app.use(express.static(path.resolve('./')));
app.use(/.*/, (req, res) => {
res.sendFile(path.resolve('index.html'));
});
return {
listen(port) {
return new Promise((resolve, reject) => {
port = port || 4777;
server.listen(port, (error) => {
if (error) {
console.error(error);
reject(error);
} else {
console.info('Listening on port %s...', port);
resolve();
}
});
});
}
};
};