-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (42 loc) · 1.09 KB
/
app.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
/* eslint-disable no-console */
const express = require("express");
const morgan = require("morgan");
const axios = require("axios");
const cors = require("cors");
const marketController = require("./controller/marketController");
const app = express();
//Development logging
if (process.env.NODE_ENV === "development") {
app.use(morgan("dev"));
}
//serving static files
app.use(express.static(`${__dirname}/src/pages`));
app.use(cors());
app.options("*", cors());
//test middleware
app.use((req, res, next) => {
req.requestTime = new Date().toISOString();
next();
});
// app.use("/market", marketController.getAllMarket);
app.use("/", async (req, res) => {
let quality = 0;
console.log("line 29 app.js", req.query.data);
my_dict = req.query.data;
console.log("line 31 app.js", my_dict);
await axios
.get(
`https://python-public-api-production.up.railway.app/?my_dict=${my_dict}`
)
.then((ans) => {
quality = ans.data;
})
.catch((err) => {
console.error(err);
quality = 0;
});
res.status(200).json({
quality,
});
});
module.exports = app;