forked from dennybritz/neal-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (28 loc) · 811 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
35
36
37
/**
* Created by xinzheng on 4/20/17.
*/
const path = require('path');
const express = require('express');
//
// const app = express();
// const indexPath = path.join(__dirname, '/public/index.html');
// const publicPath = express.static(path.join(__dirname, '/public'));
//
// app.use(publicPath);
// app.get('/', function (_, res) { res.sendFile(indexPath) });
//
const app = express();
const port = process.env.PORT || 8080;
const public_path = express.static(__dirname + '/public');
const index_path = __dirname + '/public/index.html';
app.use(public_path);
app.get('*', function (request, response) {
response.sendFile(index_path, function (error) {
if (error) {
console.log(error);
}
});
});
app.listen(port, function() {
console.log("App is running on port " + port);
});