Spaces:
Runtime error
Runtime error
| document.getElementById("upload-form").addEventListener("submit", async (e) => { | |
| e.preventDefault(); | |
| const fileInput = document.getElementById("file-input"); | |
| const formData = new FormData(); | |
| formData.append("file", fileInput.files[0]); | |
| const endpoint = fileInput.files[0].type.startsWith("image/") ? "/caption" : "/summarize"; | |
| const response = await fetch(endpoint, { | |
| method: "POST", | |
| body: formData | |
| }); | |
| const result = await response.json(); | |
| document.getElementById("result").innerText = result.summary || result.caption; | |
| }); |