udpate token - Gstar7CodeMan/testings GitHub Wiki
Certainly! Here's the updated index.html with enhanced styling using Bootstrap and additional CSS to make it more visually appealing:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tokenization Cost Estimator</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
padding-top: 20px;
background-color: #f8f9fa;
}
.container {
max-width: 800px;
margin: auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.progress {
display: none;
height: 25px;
}
.progress-bar {
line-height: 25px;
}
.btn-primary {
background-color: #007bff;
border-color: #007bff;
}
.btn-success {
background-color: #28a745;
border-color: #28a745;
}
.table {
margin-top: 20px;
}
.header {
margin-bottom: 40px;
}
.footer {
margin-top: 40px;
text-align: center;
color: #6c757d;
}
</style>
</head>
<body>
<div class="container">
<div class="header text-center">
<h1>Tokenization Cost Estimator</h1>
<p>Estimate the tokenization cost for different OpenAI models by uploading your files.</p>
</div>
<form id="uploadForm" enctype="multipart/form-data">
<div class="form-group">
<label for="fileInput">Upload your files:</label>
<input type="file" class="form-control-file" id="fileInput" name="file" multiple>
</div>
<button type="submit" class="btn btn-primary">Upload</button>
</form>
<div class="progress mt-3">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
</div>
<div id="results" class="mt-5"></div>
<button id="downloadButton" class="btn btn-success mt-3" style="display: none;">Download Report</button>
<div class="footer">
<p>© 2024 Tokenization Cost Estimator</p>
<p>For more information, visit the <a href="https://platform.openai.com" target="_blank">OpenAI Platform</a>.</p>
</div>
</div>
<script>
document.getElementById('uploadForm').addEventListener('submit', function(event) {
event.preventDefault();
var formData = new FormData();
var fileInput = document.getElementById('fileInput');
for (var i = 0; i < fileInput.files.length; i++) {
formData.append('file', fileInput.files[i]);
}
var progressBar = document.querySelector('.progress');
var progress = document.querySelector('.progress-bar');
progressBar.style.display = 'block';
progress.style.width = '0%';
progress.setAttribute('aria-valuenow', 0);
progress.textContent = '0%';
fetch('/upload/', {
method: 'POST',
body: formData
}).then(response => response.json())
.then(data => {
var resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = data.html_content;
document.getElementById('downloadButton').style.display = 'block';
progress.style.width = '100%';
progress.setAttribute('aria-valuenow', 100);
progress.textContent = '100%';
}).catch(error => {
console.error('Error:', error);
var resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = `<div class="alert alert-danger" role="alert">${error.message}</div>`;
progressBar.style.display = 'none';
});
});
document.getElementById('downloadButton').addEventListener('click', function() {
fetch('/download/')
.then(response => response.blob())
.then(blob => {
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = 'reports.zip';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
}).catch(error => {
console.error('Error:', error);
});
});
</script>
</body>
</html>- Bootstrap Integration: Integrated Bootstrap for responsive design and better styling.
- Enhanced Styling: Improved the styling with additional CSS to make the page look better.
- Progress Bar: The progress bar is now styled and animated.
- Header and Footer: Added a header with a description and a footer with copyright and links for more information.
- Error Handling: Error messages are displayed in a Bootstrap alert.
This should provide a more pleasing and user-friendly interface for the tokenization cost estimator.