Visual drag-and-drop website builder using GrapesJS with: - Multi-page editor with live preview - File-based asset storage via PHP API (no localStorage base64) - Template library, Docker support, and Playwright test suite Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
795 B
PHP
34 lines
795 B
PHP
<?php
|
|
/**
|
|
* PHP Built-in Server Router
|
|
*
|
|
* Usage: php -S localhost:8081 router.php
|
|
*
|
|
* Routes /api/* requests to api/index.php and serves all other
|
|
* requests as static files (same behavior as Apache with .htaccess).
|
|
*/
|
|
|
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
|
|
// Route API requests to the API handler
|
|
if (strpos($uri, '/api/') === 0) {
|
|
require __DIR__ . '/api/index.php';
|
|
return true;
|
|
}
|
|
|
|
// Serve static files as-is
|
|
$filePath = __DIR__ . $uri;
|
|
if ($uri !== '/' && is_file($filePath)) {
|
|
return false; // Let PHP's built-in server handle the file
|
|
}
|
|
|
|
// Default: serve index.html for directory requests
|
|
if (is_dir($filePath)) {
|
|
$indexPath = rtrim($filePath, '/') . '/index.html';
|
|
if (is_file($indexPath)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return false;
|