-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
24 lines (22 loc) · 890 Bytes
/
renderer.js
File metadata and controls
24 lines (22 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.addEventListener('DOMContentLoaded', () => {
const helloBtn = document.getElementById('hello-btn');
const apiBtn = document.getElementById('api-btn');
helloBtn.addEventListener('click', () => {
alert('Hello from Electron!');
console.log('Button was clicked!');
});
// New button for API communication
if (apiBtn) {
apiBtn.addEventListener('click', async () => {
try {
const response = await fetch('http://127.0.0.1:5000/api/hello');
const data = await response.json();
alert(`API Response: ${data.message}`);
console.log('API Response:', data);
} catch (error) {
alert('API connection error! Make sure the Python server is running.');
console.error('API Error:', error);
}
});
}
});