geothermie-atlas/app/api/pythonShell.js

23 lines
568 B
JavaScript
Raw Permalink Normal View History

2023-10-19 09:07:33 +00:00
import { PythonShell } from 'python-shell';
const scriptFile = './app/api/BHEseppy_query_V50_MWP_beta6.py';
export async function runPythonShell(options) {
try {
const results = await PythonShell.run(scriptFile, options);
let resultList = [];
if (results && results.length > 0) {
let resultString = results[results.length - 1];
resultList = resultString
.replace(/[\[\]]/g, '')
.split(',')
.map((entry) => entry.trim().replaceAll("'", ''));
}
return resultList;
} catch (e) {
console.error(e);
}
}