File size: 1,334 Bytes
94e14dc
 
 
 
 
 
 
 
1dc41b5
 
94e14dc
84e5ba3
94e14dc
84e5ba3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94e14dc
84e5ba3
 
94e14dc
 
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
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API Request</title>
</head>
<body>
    <h1>API Request</h1>
    <label for="tokenInput">Enter Token:</label>
    <input type="text" id="tokenInput" placeholder="Your Token">
    <button id="sendRequestButton">Send Request</button>
    <textarea id="responseArea" rows="10" cols="50" readonly></textarea>

<script>
    document.getElementById('sendRequestButton').addEventListener('click', function() {
        const token = document.getElementById('tokenInput').value;
        const url = '/send_request';
        fetch(url, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            body: 'token=' + encodeURIComponent(token)
        })
        .then(response => response.json())
        .then(data => {
            console.log('JSON Response:', data); // Вывод JSON-ответа в консоль
            document.getElementById('responseArea').value = JSON.stringify(data, null, 2);
        })
        .catch(error => {
            console.error('Error:', error);
            document.getElementById('responseArea').value = 'Error: ' + error.message;
        });
    });
</script>
</body>
</html>