Setup childprocess
This commit is contained in:
parent
546c09cca2
commit
56599bfdb3
@ -9,6 +9,9 @@ from data_handler import DataHandler
|
|||||||
|
|
||||||
app: Flask = Flask(__name__)
|
app: Flask = Flask(__name__)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug=True)
|
||||||
|
|
||||||
|
|
||||||
def handle_first_launched():
|
def handle_first_launched():
|
||||||
"""
|
"""
|
||||||
|
37
backend/rest_api.spec
Normal file
37
backend/rest_api.spec
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
['rest_api.py', 'encryption_handler.py', 'data_handler.py'],
|
||||||
|
pathex=[],
|
||||||
|
binaries=[],
|
||||||
|
datas=[],
|
||||||
|
hiddenimports=[],
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=[],
|
||||||
|
noarchive=False,
|
||||||
|
)
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
[],
|
||||||
|
name='rest_api',
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
upx_exclude=[],
|
||||||
|
runtime_tmpdir=None,
|
||||||
|
console=True,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
)
|
@ -1,5 +1,7 @@
|
|||||||
const { app, BrowserWindow, shell } = require('electron')
|
const { app, BrowserWindow, shell } = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const { spawn } = require('node:child_process');
|
||||||
|
const rest_api = spawn('python', ['./backend/rest_api.py']);
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
|
|
||||||
@ -21,9 +23,10 @@ function createWindow () {
|
|||||||
return { action: 'deny' };
|
return { action: 'deny' };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
win.webContents.openDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
@ -32,7 +35,23 @@ app.whenReady().then(() => {
|
|||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
rest_api.stdout.on('data', (data) => {
|
||||||
|
console.log(data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
rest_api.stderr.on('data', (data) => {
|
||||||
|
console.error(data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
rest_api.on('exit', (code) => {
|
||||||
|
console.log(`Child exited with code ${code}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('before-quit', () => {
|
||||||
|
rest_api.kill();
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
@ -46,6 +65,13 @@ app.on('web-contents-created', (event, contents) => {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
require('electron').shell.openExternal(navigationUrl);
|
require('electron').shell.openExternal(navigationUrl);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
const PORT = 5000
|
||||||
const errlabel = document.getElementById('errlabel')
|
const errlabel = document.getElementById('errlabel')
|
||||||
|
|
||||||
function validateRegister() {
|
function validateRegister() {
|
||||||
@ -40,7 +40,7 @@ async function createUser(username,password) {
|
|||||||
const errorMessage = await response.text();
|
const errorMessage = await response.text();
|
||||||
errlabel.textContentL = errorMessage;
|
errlabel.textContentL = errorMessage;
|
||||||
setTimeout(()=> {
|
setTimeout(()=> {
|
||||||
errorlabel.textContent = "";
|
errlabel.textContent = "";
|
||||||
},3000)
|
},3000)
|
||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user