commit 24ce2b9895b6b74a9e3f8d30bb896d46735e750c
parent f697b15cb768a0bda1650c5fa08337d76b4407f6
Author: markseu <mark2011@mayberg.se>
Date: Fri, 20 Dec 2019 16:45:11 +0100
Updated built-in web server
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/system/extensions/command.php b/system/extensions/command.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowCommand {
- const VERSION = "0.8.9";
+ const VERSION = "0.8.10";
const TYPE = "feature";
const PRIORITY = "3";
public $yellow; //access to API
@@ -40,7 +40,7 @@ class YellowCommand {
$help .= "build [directory location]\n";
$help .= "check [directory location]\n";
$help .= "clean [directory location]\n";
- $help .= "serve [url]\n";
+ $help .= "serve [directory url]\n";
return $help;
}
@@ -463,15 +463,21 @@ class YellowCommand {
// Process command to start built-in web server
public function processCommandServe($args) {
- list($command, $url) = $args;
+ list($command, $path, $url) = $args;
+ if (empty($path) && is_dir($this->yellow->system->get("coreStaticDir"))) $path = $this->yellow->system->get("coreStaticDir");
if (empty($url)) $url = "http://localhost:8000";
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($url);
if ($scheme=="http" && !empty($address)) {
if (!preg_match("/\:\d+$/", $address)) $address .= ":8000";
echo "Starting built-in web server on $scheme://$address/\n";
echo "Press Ctrl-C to quit...\n";
- system("php -S $address yellow.php", $returnStatus);
+ if (empty($path) || $path=="dynamic") {
+ system("php -S $address yellow.php", $returnStatus);
+ } else {
+ system("php -S $address -t $path", $returnStatus);
+ }
$statusCode = $returnStatus!=0 ? 500 : 200;
+ if ($statusCode!=200) echo "ERROR starting web server: Please check your arguments!\n";
} else {
$statusCode = 400;
echo "Yellow $command: Invalid arguments\n";