-
Notifications
You must be signed in to change notification settings - Fork 8
/
dev-server.js
97 lines (83 loc) · 2.34 KB
/
dev-server.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var path = require("path");
var express = require("express");
var webpack = require("webpack");
var config = require("./webpack.config.dev");
var request = require("request");
var app = express();
var compiler = webpack(config);
app.use(require("webpack-dev-middleware")(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require("webpack-hot-middleware")(compiler));
app.get("/Zika_meta", function(req, res) {
request("http://flu.tuebingen.mpg.de/data/H3N2_1985to2016_meta.json", function(err,r) {
if (err) {console.log('error getting data', err)}
// console.log(r.toJSON())
res.send(r.toJSON());
});
});
app.get("/Zika_tree", function(req, res) {
request({
method: "get",
uri: "http://dev.nextflu.org/data/h3n2_6y_tree.json",
gzip: true
}, function(err,r) {
if (err) {console.log('error getting data', err)}
res.send(r.toJSON());
});
});
app.get("/Zika_sequences", function(req, res) {
request({
method: "get",
uri: "http://dev.nextflu.org/data/h3n2_6y_sequences.json",
gzip: true
}, function(err,r) {
if (err) {console.log('error getting data', err)}
res.send(r.toJSON());
});
});
app.get("/Zika_frequencies", function(req, res) {
request({
method: "get",
uri: "http://dev.nextflu.org/data/h3n2_6y_frequencies.json",
gzip: true
}, function(err,r) {
if (err) {console.log('error getting data', err)}
res.send(r.toJSON());
});
});
app.get("/Zika_entropy", function(req, res) {
request({
method: "get",
uri: "http://dev.nextflu.org/data/h3n2_6y_entropy.json",
gzip: true
}, function(err,r) {
if (err) {console.log('error getting data', err)}
res.send(r.toJSON());
});
});
// app.get("/:virus/:strain/:timeperiod/:resource", function(req, res) {
// request(
// "http://nextstrain.org/data/" +
// req.params.virus +
// req.params.strain +
// req.params.timeperiod || "" +
// req.params.resource +
// ".json",
// (err,r) => {
// if (err) {console.log('error getting data', err)}
// res.send(r.toJSON());
// });
// });
app.get("*", function(req, res) {
res.sendFile(path.join(__dirname, "index.html"));
});
var port = 4000;
app.listen(port, "localhost", function(err) {
if (err) {
console.log("error", err);
return;
}
console.log("Listening at http://localhost:" + port);
});