AdityaAdaki
ap
fae4149
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Certificate Validation</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
body {
background: linear-gradient(135deg, #f5f7fa 0%, #e3e6f0 100%);
color: #2c3e50;
font-family: 'Poppins', sans-serif;
min-height: 100vh;
}
.container {
margin-top: 50px;
padding: 30px;
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
border: 1px solid #e0e0e0;
}
h1 {
font-weight: 700;
text-align: center;
margin-bottom: 40px;
font-size: 2.5rem;
color: #1a365d;
}
.upload-container {
background: #f8fafc;
border-radius: 12px;
padding: 30px;
text-align: center;
border: 2px dashed #cbd5e0;
transition: all 0.3s ease;
}
.upload-container:hover {
border-color: #4a90e2;
transform: translateY(-3px);
}
.upload-icon {
font-size: 48px;
color: #4a90e2;
margin-bottom: 15px;
}
.form-control {
background: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 8px;
color: #2d3748;
padding: 12px;
transition: all 0.3s ease;
}
.form-control:focus {
border-color: #4a90e2;
box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}
.btn-primary {
background: linear-gradient(45deg, #4a90e2, #5a9ee6);
border: none;
border-radius: 8px;
padding: 12px 30px;
font-weight: 600;
letter-spacing: 0.5px;
box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
transition: all 0.3s ease;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 15px rgba(74, 144, 226, 0.2);
background: linear-gradient(45deg, #5a9ee6, #4a90e2);
}
.table-wrapper {
margin-top: 40px;
background: #ffffff;
border-radius: 12px;
padding: 25px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
border: 1px solid #e0e0e0;
}
.table-wrapper h2 {
color: #1a365d;
font-weight: 600;
text-align: center;
margin-bottom: 25px;
font-size: 1.8rem;
}
table {
width: 100%;
border-collapse: separate;
border-spacing: 0 8px;
}
th {
background: #f8fafc;
color: #2d3748;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 0.9rem;
padding: 15px;
border-bottom: 2px solid #e2e8f0;
}
td {
background: #ffffff;
color: #2d3748;
padding: 15px;
border-bottom: 1px solid #e2e8f0;
}
tr:hover td {
background: #f8fafc;
transition: all 0.2s ease;
}
.alert-danger {
background: #fff5f5;
border: 1px solid #feb2b2;
color: #c53030;
border-radius: 8px;
padding: 15px;
}
.loading {
display: none;
text-align: center;
padding: 20px;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 5px solid #e2e8f0;
border-top: 5px solid #4a90e2;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.file-name {
margin-top: 10px;
font-size: 0.9rem;
color: #718096;
}
h4 {
color: #2d3748;
font-weight: 600;
}
.validation-results {
background: #ffffff;
border-radius: 12px;
padding: 25px;
margin-top: 30px;
}
.certificate-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25px;
padding-bottom: 15px;
border-bottom: 2px solid #e2e8f0;
}
.certificate-header h3 {
margin: 0;
color: #1a365d;
font-weight: 600;
}
.validity-badge {
padding: 8px 16px;
border-radius: 20px;
font-weight: 600;
}
.validity-badge.valid {
background-color: #c6f6d5;
color: #2f855a;
}
.validity-badge.invalid {
background-color: #fed7d7;
color: #c53030;
}
.cert-details {
width: 100%;
margin-bottom: 25px;
border-collapse: separate;
border-spacing: 0;
}
.cert-details th {
background: #f7fafc;
color: #4a5568;
font-weight: 600;
text-align: left;
padding: 12px 15px;
border-bottom: 2px solid #e2e8f0;
}
.cert-details td {
padding: 12px 15px;
border-bottom: 1px solid #e2e8f0;
}
.cert-details tr:last-child td {
border-bottom: none;
}
.cert-details tr:hover td {
background-color: #f7fafc;
}
.validity-notes {
margin-top: 20px;
padding: 15px;
background: #f8fafc;
border-radius: 8px;
color: #4a5568;
line-height: 1.6;
}
/* Responsive adjustments */
@media (max-width: 768px) {
.certificate-header {
flex-direction: column;
text-align: center;
gap: 15px;
}
.cert-details {
display: block;
overflow-x: auto;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Certificate Validation</h1>
<form method="POST" enctype="multipart/form-data" class="mb-4" id="upload-form">
<div class="upload-container mb-4">
<i class="fas fa-cloud-upload-alt upload-icon"></i>
<h4 class="mb-3">Upload Your Certificate</h4>
<input type="file" name="certificate" id="certificate" class="form-control" required accept="image/*,.pdf">
<div class="file-name" id="file-name"></div>
</div>
<button type="submit" class="btn btn-primary w-100">
<i class="fas fa-check-circle me-2"></i>Validate Certificate
</button>
</form>
<div class="loading" id="loading">
<div class="loading-spinner mb-3"></div>
<p>Processing your certificate...</p>
</div>
{% if gemini_output %}
<div class="table-wrapper">
{{ gemini_output | safe }}
</div>
{% elif error %}
<div class="alert alert-danger" role="alert">
<i class="fas fa-exclamation-circle me-2"></i>{{ error }}
</div>
{% endif %}
</div>
<script>
// Display file name when selected
document.getElementById('certificate').addEventListener('change', function(e) {
const fileName = e.target.files[0]?.name || 'No file selected';
document.getElementById('file-name').textContent = fileName;
});
// Handle form submission
document.getElementById('upload-form').addEventListener('submit', async function(e) {
e.preventDefault(); // Prevent default form submission
const form = e.target;
const loadingElement = document.getElementById('loading');
try {
// Show loading animation
loadingElement.style.display = 'block';
// Create FormData object
const formData = new FormData(form);
// Send POST request
const response = await fetch('/', {
method: 'POST',
body: formData
});
// Get the response text
const result = await response.text();
// Update the page content
document.body.innerHTML = result;
} catch (error) {
console.error('Error:', error);
alert('An error occurred while processing the certificate. Please try again.');
} finally {
// Hide loading animation
loadingElement.style.display = 'none';
}
});
</script>
</body>
</html>