$server->get('/index', function ($request, $response, $next) use($indexer) { $response->write(json_encode(array('status' => $indexer->status, 'last_indexed_file' => $indexer->last_indexed_file))); $next(); }); $server->post('/index', function ($request, $response, $next) use($indexer) { echo "Starting index...\n"; $next(); $indexer->index(); echo "Index complete.\n"; }); $server->post('/reindex', function ($request, $response, $next) use($indexer) { echo "Starting reindex...\n"; if ($request->file) { $file = realpath($request->file); $indexer->delete_file_index($file); $indexer->index_file($file); } else { $indexer->delete_index(); $indexer->index(); } echo "Indexing completed.\n"; $next(); }); $server->post('/index-php', function ($request, $response, $next) use($indexer_php) { $indexer_php->delete_index(); $indexer_php->index(); echo "Indexing Complete\n"; $next(); }); $server->post('/updateindex', function ($request, $response, $next) use($indexer) { echo "Updating reindex...\n";