我建议您应该将electron应用程序用作flask应用程序的UI。这意味着您可以使用electron启动flask服务器,然后导航到electron UI中的url。
下面是一个如何执行此操作的示例:app.on('ready', function() {
//call python?
var subpy = require('child_process').spawn('python', ['./hello.py']);
var rq = require('request-promise');
var mainAddr = 'http://localhost:5000';
var openWindow = function(){
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600});
// and load the index.html of the app.
// mainWindow.loadURL('file://' + __dirname + '/index.html');
mainWindow.loadURL('http://localhost:5000');
// Open the devtools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
// kill python
subpy.kill('SIGINT');
});
};