Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
60 lines (49 loc) · 2.05 KB
/
Copy pathserver.js
File metadata and controls
60 lines (49 loc) · 2.05 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const express = require('express');
const path = require('path');
const terrainServer = require('./terrainserver');
const webpackDevMiddleware = require("webpack-dev-middleware");
const webpackHotMiddleware = require("webpack-hot-middleware");
let app = express();
const port = (process.env.PORT || 3001);
(function() {
// Step 1: Create & configure a webpack compiler
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
const compiler = webpack(webpackConfig);
// Step 2: Attach the dev middleware to the compiler & the server
app.use(webpackDevMiddleware(compiler, {
noInfo: true, publicPath: webpackConfig.output.publicPath
}));
// Step 3: Attach the hot middleware to the compiler & the server
app.use(webpackHotMiddleware(compiler, {
log: console.log, path: '/__webpack_hmr', heartbeat: 10 * 1000
}));
})();
// Serve static files from the public folder
const publicPath = path.resolve(__dirname, 'public');
app.use(express.static(publicPath));
/* // For rendering files to jupyter notebook
app.get('/CustomMaps/:tileset/:z/:x/:y.png', function (req, res) {
const x = req.params.x;
let y = req.params.y;
const z = req.params.z;
y = 2**z-y-1;
const tileset = req.params.tileset;
console.log(path.resolve(__dirname, 'public', 'CustomMaps', tileset, z, x, y + '.png'));
//res.set('Content-Encoding', 'gzip');
res.sendFile(path.resolve(__dirname, 'public', 'CustomMaps', tileset, z, x, y + '.png'));
});*/
const cesiumPath = path.resolve(__dirname, 'node_modules', 'cesium', 'Build','Cesium');
app.use(express.static(cesiumPath));
// Host terrain tiles
// TODO: move terrain folder in here?
//const terrainPath = 'https://s3-us-west-2.amazonaws.com/sextantdata';
//const terrainPath = 'C:\\Users\\johan\\Dropbox (MIT)\\BASALT\\pextant\\data\\maps\\terrain';
//app = terrainServer(app, terrainPath);
//require("!style!css!./style.css");
app.get('/Widget', function (req, res) {
res.send('Hello world');
});
app.listen(port, function () {
console.log('Example app listening on port 3001');
});