islam_bot / index.html
Docfile's picture
Upload 2 files
56ea875
raw
history blame
2.99 kB
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Application juridique</title>
<!-- Lien vers le fichier CSS personnalisé -->
<link rel="stylesheet" href="styles.css">
<!-- Lien vers la bibliothèque Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="card mt-5">
<div class="card-header bg-primary text-white">
<h1 class="text-center">Application juridique</h1>
</div>
<div class="card-body">
<div class="form-group">
<label for="question">Posez votre question :</label>
<textarea class="form-control" id="question" rows="3" placeholder="Entrez votre question"></textarea>
</div>
<div class="text-center">
<button type="button" class="btn btn-primary" id="submitBtn">Obtenir la réponse</button>
</div>
<div id="loading" class="text-center mt-4" style="display: none;">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Chargement...</span>
</div>
</div>
<div class="mt-4 text-center">
<strong>Réponse :</strong>
<p id="answer" class="mt-2"></p>
</div>
</div>
</div>
</div>
<!-- Lien vers la bibliothèque jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<!-- Lien vers la bibliothèque Bootstrap JavaScript -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<script>
// Fonction pour gérer le clic sur le bouton de soumission
document.getElementById('submitBtn').addEventListener('click', function() {
var question = document.getElementById('question').value;
getAnswer(question);
});
// Fonction pour obtenir la réponse à partir de la question en utilisant l'API
function getAnswer(question) {
// Afficher l'indicateur de chargement
document.getElementById('loading').style.display = 'block';
// Masquer la réponse précédente
document.getElementById('answer').innerHTML = '';
fetch('https://docfile-islam.hf.space/run/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: [question]
})
})
.then(response => response.json())
.then(data => {
var answer = data.data[0];
document.getElementById('answer').innerHTML = answer;
})
.catch(error => {
console.error('Une erreur s\'est produite:', error);
})
.finally(() => {
// Masquer l'indicateur de chargement après avoir reçu la réponse
document.getElementById('loading').style.display = 'none';
});
}
</script>
</body>
</html>