Merge branch 'handle_backend_log' into for_webui
This commit is contained in:
@@ -21,16 +21,21 @@ export const useReceiveRoutes = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const receiveRoutes = (parsed_data) => {
|
const receiveRoutes = (parsed_data) => {
|
||||||
if (parsed_data.status === 200) {
|
switch (parsed_data.status) {
|
||||||
|
case 200:
|
||||||
const route = routes[parsed_data.endpoint];
|
const route = routes[parsed_data.endpoint];
|
||||||
if (route) {
|
(route) ? route({ data: parsed_data.result }) : console.error(`Invalid endpoint: ${parsed_data.endpoint}`);
|
||||||
route({ data: parsed_data.result });
|
break;
|
||||||
} else {
|
|
||||||
console.error(`Invalid path: ${parsed_data.endpoint}`);
|
case 384:
|
||||||
}
|
console.log("from backend:", parsed_data);
|
||||||
} else {
|
break;
|
||||||
console.log("Received data status is not '200'.", parsed_data);
|
|
||||||
|
default:
|
||||||
|
console.log("Received data status does not match.", parsed_data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return { receiveRoutes };
|
return { receiveRoutes };
|
||||||
};
|
};
|
||||||
@@ -13,10 +13,8 @@ export const useStartPython = () => {
|
|||||||
parsed_data = JSON.parse(line);
|
parsed_data = JSON.parse(line);
|
||||||
receiveRoutes(parsed_data);
|
receiveRoutes(parsed_data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error, line);
|
||||||
parsed_data = line;
|
|
||||||
}
|
}
|
||||||
console.log("from python:", parsed_data);
|
|
||||||
});
|
});
|
||||||
command.stderr.on("data", line => console.error("stderr:", line));
|
command.stderr.on("data", line => console.error("stderr:", line));
|
||||||
const backend_subprocess = await command.spawn();
|
const backend_subprocess = await command.spawn();
|
||||||
|
|||||||
Reference in New Issue
Block a user