-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·34 lines (28 loc) · 976 Bytes
/
index.php
File metadata and controls
executable file
·34 lines (28 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use Katzgrau\KLogger\Logger;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
use Broadview\FileHandler;
use Broadview\Environment;
require_once('./vendor/autoload.php');
$environment = new Environment('./../schedule.freespeech.org/broadview');
$logger = new Logger($environment->getLogDirectory(), Psr\Log\LogLevel::INFO, array('filename' => 'broadview-schedule'));
$app = new Application();
$app['environment'] = $environment;
$app['schedule_logger'] = $logger;
$app->get('/', function() use($app) {
$app['schedule_logger']->info('Schedule Requested.');
try {
$fh = new FileHandler($app['environment']);
$nf = $fh->getNewestFile();
$app['schedule_logger']->info('Latest Schedule: ' . $nf);
$data = $fh->getContents($nf);
return $app->json($data);
}
catch (\Exception $e) {
$app['schedule_logger']->error($e->getMessage());
return new Response('Internal Error.', 500);
}
});
$app->run();
?>