File tree 3 files changed +16
-1
lines changed 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { Link } from 'react-router-dom' ;
3
+ import path from 'path' ;
4
+ import { exec } from 'child_process' ;
3
5
import routes from '../constants/routes.json' ;
4
6
import styles from './Home.css' ;
5
7
6
8
export 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
+
7
19
return (
8
20
< div className = { styles . container } data-tid = "container" >
9
21
< h2 > Home</ h2 >
10
22
< Link to = { routes . COUNTER } > to Counter</ Link >
23
+ < button onClick = { callPython } > Call Python in console</ button >
24
+ < p > { `stdout: ${ output } ` } </ p >
11
25
</ div >
12
26
) ;
13
27
}
Original file line number Diff line number Diff line change 60
60
" app.html" ,
61
61
" main.prod.js" ,
62
62
" main.prod.js.map" ,
63
- " package.json"
63
+ " package.json" ,
64
+ " assets/"
64
65
],
65
66
"dmg" : {
66
67
"contents" : [
You can’t perform that action at this time.
0 commit comments