-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
49 lines (37 loc) · 1019 Bytes
/
Copy pathserver.js
File metadata and controls
49 lines (37 loc) · 1019 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const http = require('http');
const express = require('express');
const path = require('path');
const bodyparser = require('body-parser');
const app = new express();
const PORT = process.env.PORT || 5000
app.use(express.static('static'));
app.use(bodyparser.json());
app.use(bodyparser.urlencoded({ extended: false }));
app.post('/debug', (req, res) => {
let body = req.body;
if (body.latitude && body.longitude && body.data){
res.status(200).json({
message: "Succesfully get data",
data: body
});
}else{
res.status(400).json({
message: "Error. Bad request"
})
}
});
app.post('/to_map', (req, res) => {
let body = req.body;
if (body.latitude && body.longitude && body.data){
res.status(200).json({
message: "Succesfully get data"
});
}else{
res.status(400).json({
message: "Error. Bad request"
})
}
});
app.listen(PORT, () => {
console.log('Example app listening on port ' + PORT);
})