|
<!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>
|
|
|