Add WebGIS SPBU project documentation
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// ── GET SPBU ──────────────────────────────────────────────────────────────────
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit();
|
||||
}
|
||||
|
||||
// ── AMBIL DATA ────────────────────────────────────────────────────────────────
|
||||
try {
|
||||
$stmt = $pdo->query("SELECT * FROM spbu ORDER BY created_at DESC");
|
||||
$rows = $stmt->fetchAll();
|
||||
echo json_encode($rows);
|
||||
} catch (PDOException $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Gagal mengambil data: ' . $e->getMessage()]);
|
||||
}
|
||||
Reference in New Issue
Block a user