DataSage12's picture
Upload index.html
e5e4877 verified
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<title>Sentiment Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>body{font-family:system-ui;margin:2rem;max-width:720px} textarea{width:100%}</style>
</head>
<body>
<h1>Sentiment Demo</h1>
<p>Saisis un texte, puis clique sur “Analyser”.</p>
<textarea id="txt" rows="4" placeholder="Tapez votre texte..."></textarea><br/><br/>
<button id="btn">Analyser</button>
<pre id="out"></pre>
<script>
const out = document.getElementById('out');
document.getElementById('btn').onclick = async () => {
const text = document.getElementById('txt').value;
out.textContent = '...';
try {
const res = await fetch('/predict', {
method: 'POST', headers: {'Content-Type':'application/json'},
body: JSON.stringify({text})
});
const data = await res.json();
out.textContent = JSON.stringify(data, null, 2);
} catch (e) {
out.textContent = 'Erreur: ' + e;
}
};
</script>
</body>
</html>