-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (68 loc) · 2.52 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.lordicon.com/fudrjiwc.js"></script>
<script src="index.js"></script>
<link rel="stylesheet" href="style.css">
<title>GCCP PROJECT</title>
</head>
<body>
<main>
<div>
<h1>GCCP | Project</h1>
<p>A ML number preditor</p>
</div>
<form id="uploadForm">
<h1>Upload Image</h1>
<input type="file" class="custom-file-input" name="file" id="fileInput" required />
<button id="sub-btn" type="submit">Upload</button>
</form>
<div id="response">
No file uploaded
</div>
<div>
<p>Download sample pics</p>
<br>
<a href="#download"><lord-icon src="https://cdn.lordicon.com/albqovim.json" trigger="loop" delay="500"
colors="primary:#fedada" state="hover-1" style="width:32px;height:32px">
</lord-icon>
</a>
</div>
</main>
<section id="download">
<div class="dowload_div">
<a href="" id="d-img" download="">Download <img src="images/download-icon.png" alt=""></a>
</div>
</section>
<script>
const form = document.querySelector("#uploadForm");
const responseDiv = document.querySelector("#response");
const uploadbtn = document.getElementById("sub-btn")
form.addEventListener("submit", function (event) {
event.preventDefault();
const fileInput = document.querySelector("#fileInput");
const file = fileInput.files[0];
const formData = new FormData();
formData.append("file", file);
if(file !== undefined){
uploadbtn.innerHTML = "Proccessing..."
}
fetch("https://getprediction-gzrkj7ydfa-uc.a.run.app", {
method: "POST",
body: formData,
})
.then((response) => response.json())
.then((data) => {
responseDiv.innerHTML =
"The predicted number is " + JSON.stringify(data).slice(14, 15);
})
.then(() => {
uploadbtn.innerHTML = "Upload"
})
});
</script>
</body>
</html>