-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.html
37 lines (35 loc) · 1.02 KB
/
frontend.html
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
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title>Tag Keeper - Upload Your Garment Tag</title>
</head>
<body>
<h1>Tag Keeper</h1>
<p>Capture your garment tag to get perfect care instructions before you cut it off!</p>
<input type="file" id="imageInput">
<button id="uploadButton">Upload</button>
<pre id="result"></pre>
<script>
document.getElementById('uploadButton').addEventListener('click', function() {
const input = document.getElementById('imageInput');
if (!input.files || input.files.length === 0) {
alert("Please select an image file!");
return;
}
const formData = new FormData();
formData.append('image', input.files[0]);
fetch('/upload', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
document.getElementById('result').textContent = JSON.stringify(data, null, 2);
})
.catch(error => {
console.error('Error:', error);
});
});
</script>
</body>
</html>