File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { Link } from 'react-router-dom' ;
3+ import path from 'path' ;
4+ import { exec } from 'child_process' ;
35import routes from '../constants/routes.json' ;
46import styles from './Home.css' ;
57
68export default function Home ( ) : JSX . Element {
9+ const [ output , setOutput ] = React . useState ( '' ) ;
10+
11+ function callPython ( ) {
12+ const pythonBinary = path . join ( __dirname , 'assets' , 'python' ) ;
13+ const pythonScript = 'print("Hello World from Python")' ;
14+ exec ( `echo '${ pythonScript } ' | ${ pythonBinary } ` , ( error , stdout ) => {
15+ setOutput ( stdout ) ;
16+ } ) ;
17+ }
18+
719 return (
820 < div className = { styles . container } data-tid = "container" >
921 < h2 > Home</ h2 >
1022 < Link to = { routes . COUNTER } > to Counter</ Link >
23+ < button onClick = { callPython } > Call Python in console</ button >
24+ < p > { `stdout: ${ output } ` } </ p >
1125 </ div >
1226 ) ;
1327}
Original file line number Diff line number Diff line change 6060 " app.html" ,
6161 " main.prod.js" ,
6262 " main.prod.js.map" ,
63- " package.json"
63+ " package.json" ,
64+ " assets/"
6465 ],
6566 "dmg" : {
6667 "contents" : [
You can’t perform that action at this time.
0 commit comments