Skip to content

Commit b292e34

Browse files
Add PRE configuration file (#15)
* Add PRE configuration file * Add 'debug' configuration
1 parent 1eb8388 commit b292e34

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

backend/restapi_server.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def main():
315315
parser = argparse.ArgumentParser(description='Rapid Power Estimator Rest API Server command-line arguments.')
316316
parser.add_argument('device_file', type=str, help='Path to the input device xml file')
317317
parser.add_argument('--port', type=int, default=5000, help='Specify TCP Port to use for REST server')
318+
parser.add_argument('--debug', default=False, action='store_true', help='Enable/Disable debug mode')
318319
args = parser.parse_args()
319320

320321
# Check if the device_file exists
@@ -327,7 +328,7 @@ def main():
327328
devicemanager = DeviceManager(args.device_file)
328329

329330
# Start Rest API server
330-
app.run(debug=False, port=args.port)
331+
app.run(debug=args.debug, port=args.port)
331332

332333
if __name__ == "__main__":
333334
main()

main.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ const { app, BrowserWindow } = require("electron");
22
const { spawn } = require("child_process");
33
const path = require("node:path");
44

5+
const config = require("./rpe.config.json")
6+
57
const startFlaskServer = () => {
6-
const device_xml = path.join(__dirname, "backend/etc/device.xml");
7-
const apiServer = spawn(`python`, [
8+
9+
const device_xml = path.join(__dirname, config.device_xml);
10+
var args = [
811
path.join(__dirname, "backend/restapi_server.py"),
9-
device_xml,
10-
]);
12+
device_xml, "--port", config.port
13+
];
14+
if (config.debug === 1)
15+
args.push("--debug");
16+
const apiServer = spawn(`python`, args);
1117

1218
apiServer.stdout.on("data", (data) => {
1319
console.log(`stdout:\n${data}`);

rpe.config.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"port": 5000,
3+
"server": "http://127.0.0.1",
4+
"device_xml": "backend/etc/device.xml",
5+
"debug": 0
6+
}

src/assets/serverAPI.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { formatString } from "./common"
2-
const server = "http://127.0.0.1";
3-
const port = "5000";
2+
const config = require("./../../rpe.config.json")
3+
const server = config.server;
4+
const port = config.port;
45

56
export const devices = formatString("{0}:{1}/devices", server, port)
67

0 commit comments

Comments
 (0)