diff --git a/api.php b/api.php
new file mode 100644
index 0000000..f3bf362
--- /dev/null
+++ b/api.php
@@ -0,0 +1,15 @@
+ [
+ "success" => false,
+ "status_code" => 404
+ ],
+ 'body' => [
+ 'message' => 'That endpoint could not be found.'
+ ]
+];
+
+echo json_encode($response, JSON_PRETTY_PRINT);
diff --git a/index.php b/index.php
index 9a8be73..31b5257 100644
--- a/index.php
+++ b/index.php
@@ -8,7 +8,12 @@ try {
exit;
}
-// TODO: Init PDO.
+// Connect to database
+try {
+ $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD, PDO_OPTIONS);
+} catch (PDOException $e) {
+ echo "Critical error: " . $e->getMessage() . "
";
+}
// Starts the session
// TODO: write this to use the database to work across more than one server
@@ -29,6 +34,7 @@ if (str_ends_with($path, '/') && $path != '/') {
$routes = [
'' => function () { require 'views/home.php'; },
+ 'api' => function () { require 'api.php'; /* Handoff further routing to API script. */ }
];
//print_r($path_array);