|
<!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> |
|
|
|
<link rel="stylesheet" href="styles.css"> |
|
|
|
<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">Chatbot Islamique </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> |
|
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> |
|
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> |
|
|
|
<script> |
|
|
|
document.getElementById('submitBtn').addEventListener('click', function() { |
|
var question = document.getElementById('question').value; |
|
getAnswer(question); |
|
}); |
|
|
|
|
|
function getAnswer(question) { |
|
|
|
document.getElementById('loading').style.display = 'block'; |
|
|
|
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(() => { |
|
|
|
document.getElementById('loading').style.display = 'none'; |
|
}); |
|
} |
|
</script> |
|
</body> |
|
</html> |
|
|