Spaces:
Running
Running
<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> |