diff --git a/web/index.html b/web/index.html index d719977..ded15a7 100644 --- a/web/index.html +++ b/web/index.html @@ -69,7 +69,10 @@
- +
+ +

+
diff --git a/web/index.js b/web/index.js index c0be8e6..e574df1 100644 --- a/web/index.js +++ b/web/index.js @@ -44,9 +44,15 @@ function showCrop() { } } -async function ip() { - const resp = await fetch("dummy.txt") - console.log(await resp.text()) +async function makeCollage(req) { + const resp = await fetch("make-collage", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) + return await resp.text(); } function snap() { @@ -78,7 +84,7 @@ function snap() { const fsy = elem.offsetTop - cot const [sx, sy, ex, ey] = cpie.get().points; const photo = { - image: elem.dataset.collageImageUrl, + image: elem.dataset.collageImageUrl.slice("images/".length), crop: { start: { x: parseInt(sx), @@ -102,6 +108,13 @@ function snap() { }; req.photos.push(photo) } + console.log(JSON.stringify(req)); - ip() + (async () => { + collagFile = await makeCollage(req) + // const collageUrlA = document.createElement("a"); + const collageUrlA = document.getElementById("collage-url"); + collageUrlA.href = `collages/${collagFile}`; + collageUrlA.text = `${collagFile} generated`; + })(); }