mirror of
https://github.com/ThunixdotNet/www.git
synced 2026-01-24 07:10:18 +00:00
added terminal interface as default. old website as no-js fallback
This commit is contained in:
27
terminal/api/_bootstrap.php
Normal file
27
terminal/api/_bootstrap.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
|
||||
$rootDir = dirname(__DIR__, 2);
|
||||
if (!is_dir($rootDir)) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Invalid root directory'], JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
|
||||
function json_out(array $data, int $status = 200): void
|
||||
{
|
||||
http_response_code($status);
|
||||
try {
|
||||
echo json_encode(
|
||||
$data,
|
||||
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
http_response_code(500);
|
||||
echo '{"error":"JSON encoding failed"}';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user