File size: 2,324 Bytes
554a6f2
 
 
 
 
179259d
554a6f2
 
179259d
554a6f2
 
 
 
179259d
 
 
 
 
 
 
554a6f2
 
 
 
 
179259d
554a6f2
 
b05de99
 
 
 
 
 
 
 
 
 
 
 
 
554a6f2
 
 
 
 
179259d
 
 
 
 
 
 
 
 
b05de99
 
 
 
 
 
 
554a6f2
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Generate and Download Design</title>
    <script>
        function generateDesign() {
            // Disabilita il pulsante per evitare richieste multiple
            const button = document.getElementById("generate-button");
            button.disabled = true;
            button.innerText = "Processing...";
            
            // Esegui la chiamata fetch per attivare il comando
            fetch('/generate-design', { method: 'POST' })
            .then(() => {
                // Abilita il pulsante di download
                document.getElementById("download-button").style.display = "block";
                button.disabled = false;
                button.innerText = "Run Command";
            })
            .catch(error => {
                console.error("Error:", error);
                button.disabled = false;
                button.innerText = "Run Command";
                alert("Failed to execute the command.");
            });
        }

        function getCurrentEndpoint() {
            fetch('/current-endpoint', { method: 'GET' })
            .then(response => response.text())
            .then(data => {
                // Display the current endpoint URL on the page
                document.getElementById("current-endpoint").innerText = data;
                console.log(data);  // Log the current endpoint URL to the console
            })
            .catch(error => {
                console.error("Error:", error);
            });
        }
    </script>
</head>
<body>
    <h1>Generate Design</h1>
    
    <!-- Bottone per attivare la generazione -->
    <button id="generate-button" onclick="generateDesign()">Run Command</button>

    <br><br>

    <!-- Bottone per il download (nascosto fino a che non è pronto) -->
    <a id="download-button" href="/api/output/generato_paired_paired/images/03191_00.jpg" download style="display:none;">
        Download Image
    </a>

    <br><br>

    <!-- New Button to Get Current Endpoint -->
    <button id="current-endpoint-button" onclick="getCurrentEndpoint()">Get Current URL</button>
    
    <p id="current-endpoint"></p> <!-- Displays the current endpoint -->
</body>
</html>