File size: 2,535 Bytes
b4b32ed |
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 79 80 81 82 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document Classifier</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 40px;
}
h1 {
color: #333;
}
.container {
max-width: 600px;
margin: auto;
}
.button {
display: inline-block;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 5px;
box-shadow: 0 4px #999;
}
.button:hover {background-color: #45a049}
.button:active {
background-color: #3e8e41;
box-shadow: 0 2px #666;
transform: translateY(2px);
}
.result {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>Document Classifier</h1>
<form id="upload-form" enctype="multipart/form-data">
<label for="file">Select a PDF file to classify:</label>
<input type="file" id="file" name="file" accept="application/pdf" required>
<button type="submit" class="button">Classify Document</button>
</form>
<button id="train-button" class="button">Train Model</button>
<div id="result" class="result"></div>
</div>
<script>
document.getElementById('upload-form').onsubmit = async function(event) {
event.preventDefault();
const fileInput = document.getElementById('file');
const formData = new FormData();
formData.append('file', fileInput.files[0]);
const response = await fetch('/classify', {
method: 'POST',
body: formData
});
const result = await response.json();
document.getElementById('result').innerText = 'Label: ' + result.label + '\nText: ' + result.text;
};
document.getElementById('train-button').onclick = async function() {
const response = await fetch('/train', {
method: 'POST'
});
const result = await response.json();
alert(result.message);
};
</script>
</body>
</html>
|