getwavefromsuno / app.py
MySafeCode's picture
Update app.py
f5b96f5 verified
raw
history blame
3.16 kB
<?php
// view.php - View Suno callbacks
$logFile = 'callback_log.json';
$logData = file_exists($logFile) ? json_decode(file_get_contents($logFile), true) : [];
if (isset($_POST['clear'])) {
file_put_contents($logFile, '[]');
header('Location: view.php');
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Suno Callbacks</title>
<style>
body { font-family: Arial; padding: 20px; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #667eea; color: white; }
.success { background: #d4edda; }
.error { background: #f8d7da; }
audio { width: 200px; }
.controls { margin-bottom: 20px; }
button { background: #667eea; color: white; border: none; padding: 10px 20px; cursor: pointer; }
button:hover { background: #5a6fde; }
</style>
</head>
<body>
<h1>🎵 Suno Callbacks (<?php echo count($logData); ?>)</h1>
<div class="controls">
<form method="POST">
<button type="submit" name="clear">🗑️ Clear All Logs</button>
</form>
</div>
<?php if (empty($logData)): ?>
<p>No callbacks received yet. Callbacks will appear here when Suno API sends them.</p>
<p>Callback URL: <code>https://1hit.no/wav/cb.php</code></p>
<?php else: ?>
<table>
<tr>
<th>Time</th>
<th>Task ID</th>
<th>Status</th>
<th>Audio</th>
<th>Actions</th>
</tr>
<?php foreach(array_reverse($logData) as $log): ?>
<tr class="<?php echo (isset($log['callback_data']['code']) && $log['callback_data']['code'] == 200) ? 'success' : 'error'; ?>">
<td><?php echo htmlspecialchars($log['timestamp']); ?></td>
<td><?php echo htmlspecialchars($log['callback_data']['data']['taskId'] ?? 'N/A'); ?></td>
<td>
<?php
if (isset($log['callback_data']['code']) && $log['callback_data']['code'] == 200) {
echo '✅ Success';
} else {
echo '❌ Error';
}
?>
</td>
<td>
<?php if(isset($log['callback_data']['data']['response']['audioWavUrl'])): ?>
<audio controls src="<?php echo htmlspecialchars($log['callback_data']['data']['response']['audioWavUrl']); ?>"></audio>
<?php else: ?>
No audio
<?php endif; ?>
</td>
<td>
<?php if(isset($log['callback_data']['data']['response']['audioWavUrl'])): ?>
<a href="<?php echo htmlspecialchars($log['callback_data']['data']['response']['audioWavUrl']); ?>" download>⬇ Download</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</body>
</html>