}
         }
         closedir($dh);
     }
     usort($sessions, function ($a, $b) {
         return $a['id'] - $b['id'];
     });
     $app->render(200, array('sessions' => $sessions));
 })->name('resultIndex');
 $app->get('/:id', function ($id) use($app) {
     $session = new Session($id);
     $download = $app->request()->params('download');
     if (null != $download && $download) {
         header("Content-Disposition: attachment; filename=\"result-{$id}.json\"");
     }
     $app->render(200, $session->GetResults($app->request()->params('filters'), $app->request()->params('pageIndex'), $app->request()->params('pageSize')));
 })->name('results');
 $app->post('/:id', function ($id) use($app) {
     $session = new Session($id);
     $result = json_decode($app->request->getBody(), true);
     if (false != $result) {
         if (array_key_exists('name', $result)) {
             $index = $session->setName($result['name']);
             $app->render(200, array());
         } else {
             $index = $session->saveResult($result);
             $result['id'] = $index;
             Notify(ADMIN_TOPIC, array('action' => 'result', 'session' => $session->getInfo(), 'result' => $result));
             $app->render(200, array());
         }
     } else {