$out = array(); $out['numTraces'] = $db->getNumberOfTraces()[0]['COUNT(*)']; $out['numHops'] = $db->getNumberOfHops()[0]['COUNT(*)']; $out['hopTime'] = $time; $out['averageHopsPerRoute'] = $db->getAverageHopsPerRoute()[0]['averageHopCount']; echo json_encode($out); }); /** * Get-request to /api/info/topTraces gets the topTen traced urls for all the executed * and saved traceroutes so far. * * @return {json} Returns the topTraces info-data in a json-object. */ $app->get('/api/info/topTraces', function () { $db = new Database(); $results = $db->getTopTraces(); echo json_encode($results); }); /** * Get-request to get all hop times that are stored in the DB. */ $app->get('/api/info/hoptimes', function () { $db = new Database(); $results = $db->getAllHopTimes(); echo json_encode($results); }); /** * Get-request to get a list of contries we had hops in, as well as a count of how many times we had hops in that country. */ $app->get('/api/info/countryCount', function () { $db = new Database();