File size: 1,173 Bytes
35a837e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sentiment Analysis</title>
</head>
<body>
    <h1>Sentiment Analysis</h1>
    <form id="commentForm">
        <label for="comment">Enter your comment:</label><br>
        <textarea id="comment" name="comment" rows="4" cols="50"></textarea><br><br>
        <input type="submit" value="Analyze Sentiment">
    </form>
    <p id="result"></p>

    <script>
        document.getElementById('commentForm').addEventListener('submit', function(event) {
            event.preventDefault();
            const comment = document.getElementById('comment').value;
            fetch('/predict', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({ comment: comment }),
            })
            .then(response => response.json())
            .then(data => {
                document.getElementById('result').innerText = 'Sentiment: ' + data.sentiment;
            });
        });
    </script>
</body>
</html>