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.

31 lines
1.0 KiB

  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. $router->addRoute('POST', '/token', 'Token::token');
  12. $dispatcher = $router->getDispatcher();
  13. $request = Request::createFromGlobals();
  14. try {
  15. $response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
  16. $response->send();
  17. } catch(League\Route\Http\Exception\NotFoundException $e) {
  18. $response = new Response;
  19. $response->setStatusCode(404);
  20. $response->setContent("Not Found\n");
  21. $response->send();
  22. } catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
  23. $response = new Response;
  24. $response->setStatusCode(405);
  25. $response->setContent("Method not allowed\n");
  26. $response->send();
  27. }