BlueGit

projects-timfalken-com allianties

Files

allianties / server / router.php

router.php

router.php 503 B Download Raw
1<?php
2declare(strict_types=1);
3// php -S 127.0.0.1:8080 -t build build/router.php
4$uri = urldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/');
5$file = __DIR__ . $uri;
6if ($uri !== '/' && is_file($file)) {
7 return false;
8}
9if (str_ends_with($uri, '.php') && is_file($file)) {
10 require $file;
11 return true;
12}
13if (is_file(__DIR__ . '/index.html')) {
14 header('Content-Type: text/html; charset=utf-8');
15 readfile(__DIR__ . '/index.html');
16 return true;
17}
18return false;