-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.html
146 lines (129 loc) · 4.04 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resume Classification</title>
<style>
/* General page styling */
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f9;
color: #333;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
h1 {
color: #4CAF50;
text-align: center;
font-size: 36px;
}
p {
text-align: center;
font-size: 18px;
margin-top: 10px;
color: #555;
}
/* Form styling */
form {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
margin-top: 20px;
}
label {
font-size: 16px;
color: #333;
}
input[type="file"] {
width: 100%;
padding: 8px;
margin-top: 10px;
margin-bottom: 20px;
border: 1px solid #ddd;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
border: none;
padding: 12px 20px;
font-size: 16px;
border-radius: 4px;
cursor: pointer;
width: 100%;
}
button:hover {
background-color: #45a049;
}
/* Result box styling */
#result {
margin-top: 20px;
padding: 20px;
background-color: #e9f7e6;
border-radius: 4px;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
font-size: 18px;
text-align: center;
}
/* Responsive design for mobile */
@media (max-width: 600px) {
body {
padding: 10px;
}
h1 {
font-size: 28px;
}
form {
width: 90%;
}
}
</style>
</head>
<body>
<h1>Resume Category Prediction</h1>
<p>Upload a resume file (TXT or PDF) to predict its category.</p>
<!-- Form for file upload -->
<form id="uploadForm" enctype="multipart/form-data">
<label for="file">Choose a .txt or .pdf file:</label><br><br>
<input type="file" id="file" name="file" accept=".txt, .pdf" required><br><br>
<button type="submit">Upload and Predict</button>
</form>
<br><br>
<!-- Display the result -->
<div id="result"></div>
<script>
// JavaScript for handling the form submission and displaying results
document.getElementById("uploadForm").addEventListener("submit", async function(event) {
event.preventDefault(); // Prevent the form from submitting traditionally
const formData = new FormData();
formData.append("file", document.getElementById("file").files[0]);
try {
const response = await fetch("/predict", {
method: "POST",
body: formData
});
const result = await response.json();
// Update the result div with the prediction
if (result.category) {
document.getElementById("result").innerHTML = `<strong>Predicted Category:</strong> ${result.category}`;
} else {
document.getElementById("result").innerHTML = `<strong>Error:</strong> ${result.error}`;
}
} catch (error) {
document.getElementById("result").innerHTML = `<strong>Error:</strong> Failed to get prediction.`;
}
});
</script>
</body>
</html>