From f06c804c249c397f63bed9e6b88dca91cf0a8606 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 13 Jun 2024 16:03:44 +0200 Subject: [PATCH] Updated response handling and added 404 page The code changes include an update to the response handling in index.php. Now, it checks if the request URI is '/metrics'. If so, it continues with the previous behavior of executing a script and outputting its result. If not, it loads a new 404 error page using Twig templating engine. A new file '404.twig' has been added under templates directory which serves as a custom 404 error page. It displays the requested URI and provides a link back to '/metrics'. --- index.php | 21 ++++++++++++++++----- templates/404.twig | 12 ++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 templates/404.twig diff --git a/index.php b/index.php index bee5f0e..441d62d 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,17 @@ 'twig_cache', + ]); + echo $twig->render('404.twig', ['path' => $_SERVER["REQUEST_URI"]]); +} \ No newline at end of file diff --git a/templates/404.twig b/templates/404.twig new file mode 100644 index 0000000..f0b30e9 --- /dev/null +++ b/templates/404.twig @@ -0,0 +1,12 @@ + + + +Page Title + + + +

404 Uri {{ path }} not found

+

/metrics

+ + \ No newline at end of file