From 8332fa60beca679eaa23bd2b77bafb9a9fcff6fb Mon Sep 17 00:00:00 2001 From: carlosteixeiracruz <46865114+carlosteixeiracruz@users.noreply.github.com> Date: Sun, 7 Jul 2019 11:54:45 -0300 Subject: [PATCH 1/4] Update index.php --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 52ed57e..c96d878 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ - Date: Sun, 7 Jul 2019 12:02:17 -0300 Subject: [PATCH 2/4] Update index.php --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index c96d878..52ed57e 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ -AAA Date: Sun, 7 Jul 2019 12:02:53 -0300 Subject: [PATCH 3/4] Update index.php --- index.php | 71 +------------------------------------------------------ 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/index.php b/index.php index 52ed57e..54834bf 100644 --- a/index.php +++ b/index.php @@ -1,70 +1 @@ -load(); -} catch (Exception $e) { - error_log("No .env file found"); - } -$app->get('/', function () { - global $app; - $app->render('index.html'); -}); - -$app->get('/api/visitors', function () { - global $app; - $app->contentType('application/json'); - $visitors = array(); - if(Cloudant::Instance()->isConnected()) { - $visitors = Cloudant::Instance()->get(); - } - echo json_encode($visitors); -}); - -$app->post('/api/visitors', function() { - global $app; - $app->contentType('application/json'); - $visitor = json_decode($app->request()->getBody(), true); - if(Cloudant::Instance()->isConnected()) { - $doc = Cloudant::Instance()->post($visitor); - echo json_encode($doc); - } else { - echo json_encode($visitor); - } -}); - -$app->delete('/api/visitors/:id', function($id) { - global $app; - Cloudant::Instance()->delete($id); - $app->response()->status(204); -}); - -$app->put('/api/visitors/:id', function($id) { - global $app; - $visitor = json_decode($app->request()->getBody(), true); - echo json_encode(Cloudant::Instance()->put($id, $visitor)); -}); - -$app->run(); +XXXX From 652fff61fc0cc5cd90be2fb57feae1ec19bf30ae Mon Sep 17 00:00:00 2001 From: carlosteixeiracruz <46865114+carlosteixeiracruz@users.noreply.github.com> Date: Sun, 7 Jul 2019 12:04:30 -0300 Subject: [PATCH 4/4] Update index.php --- index.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 54834bf..bbec267 100644 --- a/index.php +++ b/index.php @@ -1 +1,71 @@ -XXXX +load(); +} catch (Exception $e) { + error_log("No .env file found"); + } +$app->get('/', function () { + global $app; + $app->render('index.html'); +}); + +$app->get('/api/visitors', function () { + global $app; + $app->contentType('application/json'); + $visitors = array(); + if(Cloudant::Instance()->isConnected()) { + $visitors = Cloudant::Instance()->get(); + } + echo json_encode($visitors); +}); + +$app->post('/api/visitors', function() { + global $app; + $app->contentType('application/json'); + $visitor = json_decode($app->request()->getBody(), true); + if(Cloudant::Instance()->isConnected()) { + $doc = Cloudant::Instance()->post($visitor); + echo json_encode($doc); + } else { + echo json_encode($visitor); + } +}); + +$app->delete('/api/visitors/:id', function($id) { + global $app; + Cloudant::Instance()->delete($id); + $app->response()->status(204); +}); + +$app->put('/api/visitors/:id', function($id) { + global $app; + $visitor = json_decode($app->request()->getBody(), true); + echo json_encode(Cloudant::Instance()->put($id, $visitor)); +}); + +$app->run(); +