File size: 3,667 Bytes
20e57f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SummaryMaker</title>
    <script>

        function toggleInput() {

            const choice = document.getElementById('choice').value;

            const urlInput = document.getElementById('urlInput');

            const fileInput = document.getElementById('fileInput');

            const textInput = document.getElementById('textInput');



            // Clear the summary box when a new input type is selected

            document.getElementById('summary').value = '';



            if (choice === 'url') {

                urlInput.style.display = 'block';

                fileInput.style.display = 'none';

                textInput.style.display = 'none';

                document.getElementById('file').value = "";

                document.getElementById('text').value = "";

            } else if (choice === 'file') {

                urlInput.style.display = 'none';

                fileInput.style.display = 'block';

                textInput.style.display = 'none';

                document.getElementById('url').value = "";

                document.getElementById('text').value = "";

            } else if (choice === 'text') {

                urlInput.style.display = 'none';

                fileInput.style.display = 'none';

                textInput.style.display = 'block';

                document.getElementById('url').value = "";

                document.getElementById('file').value = "";

            } else {

                urlInput.style.display = 'none';

                fileInput.style.display = 'none';

                textInput.style.display = 'none';

            }

        }





        function clearSummary() {

            document.getElementById('summary').value = '';

        }

    </script>
</head>
<body>
    <h1>SummaryMaker</h1>
    <form action="/summarize" method="post" enctype="multipart/form-data" onsubmit="clearSummary()">
        <label for="choice">Choose input text type:</label><br>
        <select id="choice" name="choice" onchange="toggleInput()">
            <option value="">--Select--</option>
            <option value="url">URL</option>
            <option value="file">File</option>
            <option value="text">Text</option>
        </select><br><br>

        <div id="urlInput" style="display: none;">
            <label for="url">URL to Summarize:</label><br>
            <input type="text" name="url" id="url" value="{{ url }}"><br><br>
        </div>
        
        <div id="fileInput" style="display: none;">
            <label for="file">Upload File:</label><br>
            <input type="file" name="file" id="file"><br><br>
        </div>
        
        <div id="textInput" style="display: none;">
            <label for="text">Text to Summarize:</label><br>
            <textarea name="text" id="text" rows="10" cols="50">{{ text }}</textarea><br><br>
        </div>

        <label for="model">Model:</label>
        <input type="text" name="model" id="model" value="{{ model or 't5-base' }}"><br>
        
        <label for="max_length">Max Length:</label>
        <input type="number" name="max_length" id="max_length" value="{{ max_length or 180 }}"><br><br>
        
        <input type="submit" value="Summarize">
    </form>
    {% if error %}
        <p style="color: red;">{{ error }}</p>
    {% endif %}
    <div>
        <h2>Summary:</h2>
        <textarea id="summary" rows="10" cols="50" readonly>{{ summary }}</textarea>
    </div>
</body>
</html>