Spaces:
Running
Running
File size: 1,915 Bytes
174f004 |
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 |
<!DOCTYPE html>
<html>
<head>
<title>Debug Book Service</title>
</head>
<body>
<h1>Book Service Debug</h1>
<div id="output"></div>
<script type="module">
import bookDataService from './src/bookDataService.js';
const output = document.getElementById('output');
async function debugBookService() {
try {
output.innerHTML += '<p>Loading dataset...</p>';
await bookDataService.loadDataset();
const status = bookDataService.getStatus();
output.innerHTML += `<p>Status: ${JSON.stringify(status, null, 2)}</p>`;
output.innerHTML += '<p>Getting 5 random books...</p>';
for (let i = 0; i < 5; i++) {
try {
const book = await bookDataService.getRandomBook();
output.innerHTML += `<div style="border:1px solid #ccc; margin:10px; padding:10px;">
<h3>Book ${i + 1}:</h3>
<p><strong>Title:</strong> ${book.title}</p>
<p><strong>Author:</strong> ${book.author}</p>
<p><strong>Source:</strong> ${book.source || 'local'}</p>
<p><strong>Text Length:</strong> ${book.text.length}</p>
<p><strong>Text Preview:</strong> ${book.text.substring(0, 200)}...</p>
</div>`;
} catch (error) {
output.innerHTML += `<p style="color:red">Error getting book ${i + 1}: ${error.message}</p>`;
}
}
} catch (error) {
output.innerHTML += `<p style="color:red">Error: ${error.message}</p>`;
}
}
debugBookService();
</script>
</body>
</html> |