You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
989 B

  1. <?php
  2. chdir('..');
  3. include('vendor/autoload.php');
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. $router = new League\Route\RouteCollection;
  7. $templates = new League\Plates\Engine(dirname(__FILE__).'/../views');
  8. $router->addRoute('GET', '/', 'Main::index');
  9. $router->addRoute('GET', '/parse', 'Parse::parse');
  10. $router->addRoute('POST', '/parse', 'Parse::parse');
  11. $dispatcher = $router->getDispatcher();
  12. $request = Request::createFromGlobals();
  13. try {
  14. $response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
  15. $response->send();
  16. } catch(League\Route\Http\Exception\NotFoundException $e) {
  17. $response = new Response;
  18. $response->setStatusCode(404);
  19. $response->setContent("Not Found\n");
  20. $response->send();
  21. } catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
  22. $response = new Response;
  23. $response->setStatusCode(405);
  24. $response->setContent("Method not allowed\n");
  25. $response->send();
  26. }