![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/utils/ |
<!DOCTYPE html>
<html>
<head>
<title>SoundStudioPro - Frontend Test</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.test-section { margin: 20px 0; padding: 20px; border: 1px solid #ccc; }
.success { color: green; }
.error { color: red; }
button { padding: 10px 20px; margin: 10px; }
#result { margin-top: 20px; padding: 10px; background: #f5f5f5; }
</style>
</head>
<body>
<h1>🎵 SoundStudioPro - Frontend API Test</h1>
<div class="test-section">
<h2>API Endpoint Test</h2>
<p>Testing the API endpoint configuration...</p>
<div id="endpointResult"></div>
</div>
<div class="test-section">
<h2>API Request Test</h2>
<button onclick="testAPI()">Test API Request</button>
<div id="apiResult"></div>
</div>
<div class="test-section">
<h2>JSON Parsing Test</h2>
<button onclick="testJSONParsing()">Test JSON Parsing</button>
<div id="jsonResult"></div>
</div>
<div id="result"></div>
<script>
// Test API endpoint configuration
const API_ENDPOINT = window.location.protocol + '//' + window.location.host + '/api.php';
document.getElementById('endpointResult').innerHTML =
`<span class="success">✅ API Endpoint: ${API_ENDPOINT}</span>`;
// Test API request
async function testAPI() {
const resultDiv = document.getElementById('apiResult');
resultDiv.innerHTML = 'Testing...';
try {
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'music',
prompt: 'Test melody for frontend',
model: 'v3',
duration: 30
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const responseText = await response.text();
console.log('Raw response:', responseText);
const result = JSON.parse(responseText);
if (result.success) {
resultDiv.innerHTML = `<span class="success">✅ API Request Successful!</span><br>
<pre>${JSON.stringify(result, null, 2)}</pre>`;
} else {
resultDiv.innerHTML = `<span class="error">❌ API Error: ${result.error}</span>`;
}
} catch (error) {
resultDiv.innerHTML = `<span class="error">❌ API Test Failed: ${error.message}</span>`;
console.error('API test error:', error);
}
}
// Test JSON parsing
function testJSONParsing() {
const resultDiv = document.getElementById('jsonResult');
// Test valid JSON
try {
const validJSON = '{"success":true,"data":{"test":"value"}}';
const parsed = JSON.parse(validJSON);
resultDiv.innerHTML = `<span class="success">✅ JSON Parsing Works!</span><br>
<pre>${JSON.stringify(parsed, null, 2)}</pre>`;
} catch (error) {
resultDiv.innerHTML = `<span class="error">❌ JSON Parsing Failed: ${error.message}</span>`;
}
}
</script>
</body>
</html>