djo*_*djo 9 python scikit-learn reactjs next.js
Next.js 是否可以调用 python 脚本在服务器端运行?我正在尝试设置一种方法来调用我已经开发的一些Python包,这些包可以在我的网站上运行,这些包是通过React.js + Next.js构建的。我希望整合一些 sklearn 方法。感谢您的任何建议。
服务器启动时
如果您想在 Next.js 服务器启动时运行脚本并在 package.json 中创建一个脚本并在之前运行它npm start
"scripts": {
"prestart": "sh ./make-coffee.sh",
"start": "next start"
},
Run Code Online (Sandbox Code Playgroud)
来自 Node.js
如果您想从 Node.js(Next.js) 代码运行脚本,请使用 Child process Doc
const { exec } = require('child_process');
exec('"file/test.sh" arg1 arg2');
Run Code Online (Sandbox Code Playgroud)
休息API
为 python 脚本创建 REST API 并从 next.js 服务器调用
| 归档时间: |
|
| 查看次数: |
10994 次 |
| 最近记录: |