commit c220652b75a698e3dc5ac80a017455035d6a8131
parent aba6585eab32d387cc3cbd835231e5fc198abb62
Author: Gerco van Woudenbergh <[email protected]>
Date: Wed, 28 Jun 2023 01:58:08 +0200
added api.php this will be the home of the logic fetching data from data base encoding to json and echoing to the uri /data
Diffstat:
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/api/api.php b/api/api.php
@@ -2,5 +2,11 @@
$api = function(&$vars){
global $db;
-
+ $json = "";
+ foreach(headers_list() as $header){
+ $json .= $header;
+ }
+ $json .= "blablab";
+ echo $json;
};
+?>
+\ No newline at end of file
diff --git a/index.php b/index.php
@@ -1,17 +1,19 @@
<?php
-require "utils/router.php";
+use Lollipop\TemplateMethods;
+require_once "utils/autoloader.php";
require_once "api/api.php";
-$router = new Router();
-
+$template = new Lollipop\Template(new TemplateMethods);
+$router = new Lollipop\Router($template);
+$db = new Lollipop\SQLDatabase("86.92.67.21", "friedel", "hailiwa", "lollipop");
$router->addRoute(['GET'], '/', 'views/homepage.php');
//Api all data
-$router->addRoute(['GET'], '/api/:token', $api);
+$router->addRoute(['GET', 'POST'], '/data', $api);
//api graph data
-$router->addRoute(['GET'], '/api/:token/graph', $api);
+$router->addRoute(['GET'], '/data/graph', $api);
//add contract
$router->addRoute(['GET', 'POST'], '/add_contract', 'views/add_contract.php');
@@ -68,4 +70,4 @@ $router->addRoute(['POST'], '/logout', 'logic/logout.php');
$router->addRoute(['POST'], '/weather_data', 'logic/postWeatherData.php');
//404
-$router->route('views/404.html');
-\ No newline at end of file
+$router->route();
+\ No newline at end of file