diff --git a/homepage/index.php b/homepage/index.php index cff395a..3f24eda 100644 --- a/homepage/index.php +++ b/homepage/index.php @@ -1,5 +1,12 @@ get_image($sci_name); + + if ($result == false) { + http_response_code(404); + echo "Error 404! No image found!"; + } else { + http_response_code(200); + header('Content-Type: application/json'); + echo json_encode([ + "status" => "success", + "message" => "successfully image data from database", + "data" => $result + ]); + } +} else { + http_response_code(404); + echo "Error 404! No route found!"; +} + +function sendResponse405() { + http_response_code(405); + echo json_encode(["message" => "Method Not Allowed"]); +}