Skip to content

Instantly share code, notes, and snippets.

@bobmagicii
Last active March 23, 2021 17:22
Show Gist options
  • Save bobmagicii/0adf9979b6822920ba46c3fd6a4462bb to your computer and use it in GitHub Desktop.
Save bobmagicii/0adf9979b6822920ba46c3fd6a4462bb to your computer and use it in GitHub Desktop.
<?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