Update static/js/script.js
Browse files- static/js/script.js +19 -9
static/js/script.js
CHANGED
@@ -45,15 +45,25 @@ class InkBoard {
|
|
45 |
this.setButtonLoading(true);
|
46 |
|
47 |
const response = await fetch('/generate', {
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
const data = await response.json();
|
58 |
|
59 |
if (data.success) {
|
|
|
45 |
this.setButtonLoading(true);
|
46 |
|
47 |
const response = await fetch('/generate', {
|
48 |
+
method: 'POST',
|
49 |
+
headers: { 'Content-Type': 'application/json' },
|
50 |
+
body: JSON.stringify({ scene_idea: userInput })
|
51 |
+
})
|
52 |
+
.then(res => {
|
53 |
+
if (!res.ok) throw new Error("Server error");
|
54 |
+
return res.json();
|
55 |
+
})
|
56 |
+
.then(data => {
|
57 |
+
if (data.error) throw new Error(data.error);
|
58 |
+
displayStory(data.story);
|
59 |
+
displayImage(data.image_url);
|
60 |
+
})
|
61 |
+
.catch(err => {
|
62 |
+
console.error("Fetch error:", err.message);
|
63 |
+
alert("Oops! " + err.message);
|
64 |
+
});
|
65 |
+
|
66 |
+
|
67 |
const data = await response.json();
|
68 |
|
69 |
if (data.success) {
|