File size: 4,115 Bytes
8befdfa
976c341
8befdfa
 
 
 
 
 
 
 
976c341
8befdfa
 
 
976c341
8befdfa
 
 
 
976c341
8befdfa
 
 
 
 
976c341
8befdfa
 
 
 
 
976c341
8befdfa
 
 
 
 
 
 
 
976c341
8befdfa
 
 
 
 
976c341
 
 
 
 
8befdfa
 
 
976c341
 
 
 
 
 
8befdfa
 
 
 
976c341
8befdfa
976c341
 
8befdfa
976c341
 
8befdfa
 
562b2de
976c341
 
 
8befdfa
 
 
 
4c1b37a
562b2de
 
976c341
8befdfa
 
976c341
 
8befdfa
 
 
 
 
976c341
8befdfa
976c341
 
8befdfa
 
976c341
 
 
8befdfa
 
 
 
 
 
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test /add_points_and_refresh_fn API</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.js"></script>
</head>
<body class="bg-gray-100 p-8">
    <div class="max-w-2xl mx-auto bg-white rounded-lg shadow-lg p-6">
        <h1 class="text-3xl font-bold mb-6">API ν…ŒμŠ€νŠΈ</h1>
        
        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2" for="email">
                이메일
            </label>
            <input type="email" 
                   id="email" 
                   class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
                   placeholder="이메일을 μž…λ ₯ν•˜μ„Έμš”">
        </div>

        <div class="mb-4">
            <button id="submit" 
                    class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
                제좜
            </button>
        </div>

        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2">
                μƒνƒœ
            </label>
            <div id="status" 
                 class="border rounded w-full py-2 px-3 text-gray-700 bg-gray-100">
            </div>
        </div>

        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2">
                κ²°κ³Όκ°’
            </label>
            <div id="value" 
                 class="border rounded w-full py-2 px-3 text-gray-700 bg-gray-100">
            </div>
        </div>

        <div id="debug" class="mt-4 p-4 bg-gray-200 rounded">
            <h2 class="font-bold mb-2">디버그 정보</h2>
            <pre id="debug-info" class="whitespace-pre-wrap"></pre>
        </div>
    </div>

    <script>
        function log(message) {
            const debugInfo = document.getElementById('debug-info');
            debugInfo.textContent += message + '\n';
            console.log(message);
        }

        document.getElementById('submit').addEventListener('click', async () => {
            const email = document.getElementById('email').value;
            const statusElement = document.getElementById('status');
            const valueElement = document.getElementById('value');
            document.getElementById('debug-info').textContent = ''; // 디버그 정보 μ΄ˆκΈ°ν™”

            // μƒνƒœ μ΄ˆκΈ°ν™”
            statusElement.textContent = 'μ²˜λ¦¬μ€‘...';
            valueElement.innerHTML = '';
            
            log(`이메일 μž…λ ₯κ°’: ${email}`);

            try {
                const apiUrl = 'https://ginipick-dokdo-pay.hf.space/api/predict/';
                log(`API 호좜 μ‹œμž‘: ${apiUrl}`);

                const response = await fetch(apiUrl, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        data: [email],
                        fn_index: 0
                    })
                });

                log(`응닡 μƒνƒœ: ${response.status}`);
                
                if (!response.ok) {
                    throw new Error(`HTTP error! status: ${response.status}`);
                }

                const data = await response.json();
                log(`응닡 데이터: ${JSON.stringify(data, null, 2)}`);
                
                statusElement.textContent = data[0] || '응닡 μ—†μŒ';
                valueElement.innerHTML = data[1] || '응닡 μ—†μŒ';

            } catch (error) {
                log(`μ—λŸ¬ λ°œμƒ: ${error.message}`);
                statusElement.textContent = `μ—λŸ¬: ${error.message}`;
                valueElement.innerHTML = 'μ—λŸ¬ λ°œμƒ';
                console.error('Error:', error);
            }
        });
    </script>
</body>
</html>