-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (30 loc) · 884 Bytes
/
Copy pathserver.js
File metadata and controls
39 lines (30 loc) · 884 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
// TODO Fix exception handling
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
const port = process.env.PORT || 5000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get("/api/hello", (req, res) => {
res.send({ express: "Hello From Express" });
});
app.post("/api/LoadTable", (req, res) => {
const retVal = {
Message: null,
Data: null,
};
try {
const tabletojson = require("tabletojson").Tabletojson;
tabletojson.convertUrl(req.body.post, function (tablesAsJson) {
//res.send(tablesAsJson);
retVal.Data = tablesAsJson;
retVal.Message = "data";
res.send(retVal);
});
} catch (e) {
retVal.Data = e;
retVal.Message = "exception";
res.send(retVal);
}
});
app.listen(port, () => console.log(`Listening on port ${port}`));