Fix docs_check and upload endpoint

This commit is contained in:
Akshay
2023-10-15 21:31:02 +05:30
parent e71d21fc27
commit cdfcd99695
2 changed files with 13 additions and 4 deletions

View File

@@ -225,5 +225,8 @@
"version": "0.1.0"
}
],
"conversations": []
"conversations": [],
"docs_check" : {
"status": "loaded"
}
}

View File

@@ -10,6 +10,8 @@ const localStorage = [];
server.use(middlewares);
server.use(jsonServer.rewriter(routes));
server.use((req, res, next) => {
if (req.method === "POST") {
if (req.url.includes("/delete_conversation")) {
@@ -22,11 +24,14 @@ server.use((req, res, next) => {
next();
});
server.use(jsonServer.rewriter(routes));
router.render = (req, res) => {
if (req.url === "/feedback") {
res.status(200).jsonp({ status: "ok" });
} else if (req.url === '/upload') {
res.status(200).jsonp({
"status": "ok",
"task_id": localStorage[localStorage.length - 1]
})
} else if (req.url.includes("/task_status")) {
const taskId = req.query["task_id"];
const taskIdExists = localStorage.includes(taskId);
@@ -44,8 +49,9 @@ router.render = (req, res) => {
} else {
res.status(404).jsonp({});
}
}else {
res.status(res.statusCode).jsonp(res.locals.data);
}
res.status(res.statusCode).jsonp(res.locals.data);
};
server.use(router);