Create webapp.php

This commit is contained in:
Namhyeon Go 2019-02-23 03:15:06 +09:00 committed by GitHub
parent e6553f919e
commit 0b5ffc1579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

17
route/webapp.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$routes = read_route_all();
$webapp_root = $_SERVER["DOCUMENT_ROOT"] . "webapp";
// set DOCUMENT_ROOT forcely
$_SERVER["DOCUMENT_ROOT"] = $webapp_root;
// set file path
$appfile_path = $webapp_root . "/" . implode("/", array_slice($routes, 1)) . ".php";
// load file
if(file_exists($appfile_path)) {
include($appfile_path);
} else {
set_error("404 Not Found");
show_errors();
}