File size: 2,992 Bytes
56ea875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!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>