BF / public /api.html
SamiKoen's picture
Add FastAPI with CORS for standalone dashboard
ff792ca
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>BF Conversations API</title>
<script>
// This page serves as a simple API endpoint
// It reads conversations.json and outputs it as JSON
async function loadAndServe() {
try {
const response = await fetch('../conversations.json');
const data = await response.json();
// Output JSON to page
document.body.textContent = JSON.stringify(data, null, 2);
document.body.style.whiteSpace = 'pre';
document.body.style.fontFamily = 'monospace';
// Also set CORS headers via meta tags (won't work but worth trying)
const meta = document.createElement('meta');
meta.httpEquiv = 'Access-Control-Allow-Origin';
meta.content = '*';
document.head.appendChild(meta);
} catch (error) {
document.body.textContent = JSON.stringify({error: error.message});
}
}
loadAndServe();
</script>
</head>
<body>
Loading...
</body>
</html>