mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
this without issues in prod tho. and the "BlurPageBeforeLogin" thing works just file, oh and checkCookie is now working (but without the database part just yet)
21 lines
554 B
TypeScript
21 lines
554 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
const slug = getRouterParam(event, "slug");
|
|
return new Promise((resolve, reject) => {
|
|
const pythonProcess = spawn("python3", ["scraping/hot_articles.py"]);
|
|
|
|
let dataString = "";
|
|
|
|
pythonProcess.stdout.on("data", (data) => {
|
|
dataString += data.toString();
|
|
});
|
|
|
|
pythonProcess.stderr.on("data", (data) => {
|
|
console.error(`Error: ${data}`);
|
|
});
|
|
|
|
pythonProcess.on("close", (code) => {
|
|
resolve({ status: "completed", output: dataString });
|
|
});
|
|
});
|
|
});
|