news-analyze/server/api/news/get/lt/[slug].ts
吳元皓 81012f5061 Made the line_today.py kinda work ig. But I have no idea how can I run
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)
2025-05-17 23:31:55 +08:00

20 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 });
});
});
});