AIProject / static /script.js
Soltane777's picture
Upload 2 files
662b3c5 verified
raw
history blame contribute delete
590 Bytes
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;
});