go
This commit is contained in:
40
api/index.php
Normal file
40
api/index.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// api/index.php
|
||||
|
||||
// Optional: zentrale Config laden (wenn du magst)
|
||||
// require __DIR__ . '/../config/fileload.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(204);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Pfad aus der URL holen, z.B. /quickcheck?...
|
||||
$uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
|
||||
$path = rtrim($uri, '/');
|
||||
if ($path === '') {
|
||||
$path = '/';
|
||||
}
|
||||
|
||||
// Routing
|
||||
switch ($path) {
|
||||
case '/quickcheck':
|
||||
require __DIR__ . '/target/quickcheck.php';
|
||||
$result = quickcheck_handle_request(); // Funktion in quickcheck.php
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
break;
|
||||
|
||||
default:
|
||||
http_response_code(404);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'error' => 'Unknown endpoint',
|
||||
'path' => $path,
|
||||
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
break;
|
||||
}
|
||||
Reference in New Issue
Block a user