/
2gc
/
Wine-Bot
Обзор
Документация
Войти
/
2gc
/
Wine-Bot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/testing/test-api.html
80 строк
3 KB
Maksim Lanies
chore: sync all changed, deleted, and new files (docs, src, tests, etc)
23 июл 2025, 04:21
23 июл 2025, 04:21
28544f0
Код
Авторство
О чём код?
<!DOCTYPE html> <html> <head> <title>API Test</title> </head> <body> <h1>API Test</h1> <button onclick="testUserStats()">Test User Stats</button> <button onclick="testDatabase()">Test Database</button> <div id="result"></div> <script> async function testUserStats() { const resultDiv = document.getElementById('result'); resultDiv.innerHTML = 'Testing user-stats...'; try { const response = await fetch('https://wine.2gc.ru/user-stats?chatId=194832010', { headers: { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36' } }); resultDiv.innerHTML = ` <h3>User Stats Response:</h3> <p>Status: ${response.status}</p> <p>Headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}</p> `; const text = await response.text(); resultDiv.innerHTML += `<p>Response Text: ${text}</p>`; if (text) { try { const json = JSON.parse(text); resultDiv.innerHTML += `<p>Parsed JSON: ${JSON.stringify(json, null, 2)}</p>`; } catch (e) { resultDiv.innerHTML += `<p>JSON Parse Error: ${e.message}</p>`; } } } catch (error) { resultDiv.innerHTML = `<p>Error: ${error.message}</p>`; } } async function testDatabase() { const resultDiv = document.getElementById('result'); resultDiv.innerHTML = 'Testing database...'; try { const response = await fetch('https://wine.2gc.ru/test-db', { headers: { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36' } }); resultDiv.innerHTML = ` <h3>Database Test Response:</h3> <p>Status: ${response.status}</p> <p>Headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}</p> `; const text = await response.text(); resultDiv.innerHTML += `<p>Response Text: ${text}</p>`; if (text) { try { const json = JSON.parse(text); resultDiv.innerHTML += `<p>Parsed JSON: ${JSON.stringify(json, null, 2)}</p>`; } catch (e) { resultDiv.innerHTML += `<p>JSON Parse Error: ${e.message}</p>`; } } } catch (error) { resultDiv.innerHTML = `<p>Error: ${error.message}</p>`; } } </script> </body> </html>