"API endpoint not found")); } } else { // Serve static files or return 404 $file_path = __DIR__ . $path; if ($path === '/' || $path === '/index.html') { // Serve a simple index page http_response_code(200); echo "

Inventory API Server

"; echo "

API is running on port 8080

"; echo "

Available endpoints:

"; echo ""; } elseif (file_exists($file_path) && is_file($file_path)) { // Serve static files $mime_types = array( 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'html' => 'text/html', 'txt' => 'text/plain' ); $extension = pathinfo($file_path, PATHINFO_EXTENSION); if (isset($mime_types[$extension])) { header("Content-Type: " . $mime_types[$extension]); } readfile($file_path); } else { // Return 404 for other requests http_response_code(404); echo json_encode(array("message" => "Not found")); } } ?>