forked from DynamoDS/librarie.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 764 Bytes
/
index.js
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
var fs = require("fs");
var express = require("express");
var app = express();
function loadJsonFromFile(jsonPath, req, res) {
fs.readFile(jsonPath, function(err, data) {
if (err) {
res.end(err.message);
} else {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(data.toString());
}
});
}
app.use(express.static(__dirname));
app.get("/", function (req, res) {
res.render("index.html");
});
app.get("/loadedTypes", function(req, res) {
loadJsonFromFile("./docs/RawTypeData.json", req, res);
});
app.get("/layoutSpecs", function(req, res) {
loadJsonFromFile("./docs/LayoutSpecs.json", req, res);
});
app.listen(3456, function () {
console.log('Library hosting service listening on port 3456');
});