-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
43 lines (34 loc) · 1.14 KB
/
server.js
File metadata and controls
43 lines (34 loc) · 1.14 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
const express = require('express');
const app = express();
const path = require('path');
const routes = express.Router();
//segmentFinder
const main = require('./main.js');
const multer = require('multer');
const bodyParser = require('body-parser');
//const passport = require('passport');
//const LocalStrategy = require('passport-local').Strategy;
const port = 8125;
const server_ip_address = '0.0.0.0' || '127.0.0.1';
routes.get('/', function (req, res, next) {
res.sendFile(__dirname + '/webview/index.html');
});
const destination = multer.diskStorage({
destination: 'gpxTracks/',
filename: function ( req, file, cb ) {
cb( null, `testGpx.gpx`);
}
}
);
const upload = multer({ storage: destination });
routes.post('/processFile', upload.single('gpx'), function (req, res, next) {
(async()=>{
let segments = await main.processFile('./gpxTracks/testGpx.gpx', false, 200);
res.json(segments);
})();
});
app.use(express.static(__dirname + '/webview'));
app.use('/', routes);
app.listen(port, server_ip_address, function () {
console.log(`Listening at ip ${server_ip_address} on port ${port}`);
});