File size: 1,098 Bytes
e108154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sketch Prediction</title>
</head>
<body>
    <h1>Sketch Prediction</h1>
    <form id="uploadForm" enctype="multipart/form-data">
        <input type="file" id="fileInput" name="file" accept="image/*">
        <button type="submit">Submit</button>
    </form>
    <div id="result"></div>

    <script>
        document.getElementById('uploadForm').addEventListener('submit', async function(event) {
            event.preventDefault();
            const formData = new FormData();
            formData.append('file', document.getElementById('fileInput').files[0]);

            const response = await fetch('/predict/', {
                method: 'POST',
                body: formData
            });

            const data = await response.blob();
            const url = URL.createObjectURL(data);
            document.getElementById('result').innerHTML = `<img src="${url}" alt="Prediction Result">`;
        });
    </script>
</body>
</html>