Skip to content

Commit d1eddcd

Browse files
committed
Update adding-assets with example
1 parent ff8cbe8 commit d1eddcd

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
17.3 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
3+
import path from 'path';
4+
import { exec } from 'child_process';
35
import routes from '../constants/routes.json';
46
import styles from './Home.css';
57

68
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+
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
}

examples/adding-assets/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
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": [

0 commit comments

Comments
 (0)