kiit-kaffe / index.php
Kush-Singh-26
Make base path environment-aware for HF Spaces
d3e050b
Raw
History Blame Contribute Delete
1.02 kB
<?php include 'includes/head.php'; ?>
<body>
<?php
// Basic Routing for PHP to pass initial page to JS
$request = $_SERVER['REQUEST_URI'];
// Detect environment and set base path accordingly
$isDocker = getenv('DOCKER_ENV') || file_exists('/var/www/html/Dockerfile');
$base = $isDocker ? '/' : '/KIIT-KAFE/';
$path = str_replace($base, '', $request);
$path = strtok($path, '?'); // Strip query params
$path = trim($path, '/');
// Map empty or "index.php" to "landing"
if (empty($path) || $path === 'index.php') $path = 'landing';
echo "<script>window.initialPage = '$path';</script>";
include 'includes/landing.php';
include 'includes/auth.php';
include 'includes/menu.php';
include 'includes/cart.php';
include 'includes/payment.php';
include 'includes/success.php';
include 'includes/admin.php';
include 'includes/modals.php';
include 'includes/scripts.php';
?>
</body>
</html>