-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (32 loc) · 1.06 KB
/
server.js
File metadata and controls
38 lines (32 loc) · 1.06 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
var fs = require('fs'),
express = require('express'),
createAllBuildingsSTL = require('./allBuildingsSTL.js').allBuildingsSTL,
buildSTL = require('./buildSTL.js').buildSTL,
buildOSM = require('./buildOSM.js').buildOSM,
bodyParser = require('body-parser');
var app = express();
app.use(express.static(__dirname + '/public/'));
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({
extended: true
}));
app.get('*', function(req, res) {
res.sendFile(__dirname + '/public/place.html');
});
app.post('/createSTL', function(req, res) {
console.log(req.body);
fs.writeFileSync('buildingsM.json', JSON.stringify(req.body));
buildSTL(req.body.buildings);
});
app.post('/createOSM', function(req, res) {
console.log(req.body);
buildOSM(req.body.buildings);
});
app.post('/createOneSTL', function(req, res) {
res.send("Stl File Created");
});
app.post('/createAllBuildingsSTL', function(req, res) {
createAllBuildingsSTL(req.body.buildings);
res.send("Stl File Created");
});
app.listen(8000);