Last active
March 23, 2021 17:22
-
-
Save bobmagicii/0adf9979b6822920ba46c3fd6a4462bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// php -S localhost:80 -t www www/index.php | |
$Root = dirname(__FILE__); | |
$Mime = NULL; | |
$File = match($_SERVER['REQUEST_URI']) { | |
'/' => "{$Root}/index.html", | |
default => "{$Root}{$_SERVER['REQUEST_URI']}" | |
}; | |
$Info = pathinfo($File); | |
if(file_exists($File)) | |
if(array_key_exists('extension',$Info)) { | |
$Mime = match($Info['extension']) { | |
'js' => 'text/javascript', | |
'babylon' => 'application/json', | |
'fx' => 'plain/text', | |
default => mime_content_type($File) | |
}; | |
if($Mime) { | |
header(sprintf('Content-Type: %s',$Mime)); | |
readfile($File); | |
return TRUE; | |
} | |
} | |
return FALSE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment