70 lines
2.4 KiB
PHP
Executable file
70 lines
2.4 KiB
PHP
Executable file
<?php
|
|
/**
|
|
* Quick API status checker
|
|
*/
|
|
require_once 'config.php';
|
|
|
|
// Require authentication
|
|
requireAuth();
|
|
|
|
$user = getCurrentUser();
|
|
|
|
echo "<h2>API Status Check</h2>";
|
|
echo "<p>Logged in as: <strong>" . htmlspecialchars($user['name']) . "</strong> (" . htmlspecialchars($user['email']) . ")</p>";
|
|
|
|
// Check if Python API is responding
|
|
$ch = curl_init(PYTHON_API_URL . '/health');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
|
|
|
|
$response = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
$error = curl_error($ch);
|
|
curl_close($ch);
|
|
|
|
echo "<div style='font-family: monospace; padding: 20px; background: #f5f5f5; border-radius: 8px;'>";
|
|
|
|
if ($httpCode === 200) {
|
|
echo "<div style='color: green; font-size: 18px; font-weight: bold;'>✓ Python API is RUNNING</div>";
|
|
echo "<div>URL: " . PYTHON_API_URL . "</div>";
|
|
echo "<div>Response: " . htmlspecialchars($response) . "</div>";
|
|
} else {
|
|
echo "<div style='color: red; font-size: 18px; font-weight: bold;'>✗ Python API is NOT RUNNING</div>";
|
|
echo "<div>URL: " . PYTHON_API_URL . "</div>";
|
|
echo "<div>HTTP Code: " . $httpCode . "</div>";
|
|
echo "<div>Error: " . htmlspecialchars($error) . "</div>";
|
|
echo "<br>";
|
|
echo "<div style='background: #fff3cd; padding: 10px; border-left: 4px solid #ffc107;'>";
|
|
echo "<strong>To start the API:</strong><br>";
|
|
echo "1. Open Terminal<br>";
|
|
echo "2. Navigate to: " . __DIR__ . "<br>";
|
|
echo "3. Run: <code>./start_api.sh</code><br>";
|
|
echo "</div>";
|
|
}
|
|
|
|
echo "</div>";
|
|
|
|
// Check outputs directory
|
|
echo "<h2>Outputs Directory</h2>";
|
|
$outputDir = __DIR__ . '/outputs/';
|
|
if (is_dir($outputDir)) {
|
|
$files = array_diff(scandir($outputDir), ['.', '..', '.DS_Store']);
|
|
echo "<div style='font-family: monospace; padding: 20px; background: #f5f5f5; border-radius: 8px;'>";
|
|
echo "Directory: " . $outputDir . "<br>";
|
|
echo "Files: " . count($files) . "<br><br>";
|
|
|
|
if (count($files) > 0) {
|
|
echo "<ul>";
|
|
foreach ($files as $file) {
|
|
$size = filesize($outputDir . $file);
|
|
echo "<li>" . htmlspecialchars($file) . " (" . number_format($size) . " bytes)</li>";
|
|
}
|
|
echo "</ul>";
|
|
} else {
|
|
echo "<em>No files in outputs directory</em>";
|
|
}
|
|
echo "</div>";
|
|
} else {
|
|
echo "<div style='color: red;'>Outputs directory does not exist!</div>";
|
|
}
|
|
?>
|