-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (24 loc) · 834 Bytes
/
Copy pathscript.js
File metadata and controls
27 lines (24 loc) · 834 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
25
26
27
document.getElementById('startBot').addEventListener('click', async () => {
const prompt = document.getElementById('prompt').value;
if (prompt.trim() === '') {
alert('Bitte gib einen Prompt ein!');
return;
}
try {
const response = await fetch('/start-bot', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt })
});
if (!response.ok) {
throw new Error('Fehler beim Starten des Bots');
}
const result = await response.text();
document.getElementById('resultBox').textContent = result;
} catch (error) {
console.error('Fehler:', error);
alert('Ein Fehler ist aufgetreten.');
}
});