Function http_server_for_dir
http_server_for_dir(arg1, arg2, ...)
starts a local http server with Python at a local
directory <dir>. At default, <dir> is the actual working
directory.
Open a web brower and surf to address:
http://0.0.0.0:<port>/
where <port> stands for the port number. It is 8000 at
default.
The local http server can be launched in a separate
window, if the terminal emulation program "qterminal" is
available. This is tried at default.
The following input arguments can be given in any ordre:
-- an integer for the port number <port>
-- string "nowindow" to prohibit launching the local http
server in a separate window;
-- any other string, which is interpreted as the
directory <dir>.
So, if "nowindow" is given as an input argument, or if no
qterminal program is available, the local http server is
started in the octave cli where you are working. Hit
control-c to stop the local http server, and then you can
continue with typing octave commands.
Internally, a call similar to this is eventually made:
system("python3 -m http.server --directory <dir> <port>");
The function internally calls the following non-standard
m-files:
-- ensure_ending_with_slash.m
-- ensure_unix_style_path.m
(c) 2026 fabien van mook
2026.08.20 release of this file within package "fvm-miscellaneous" under GNU GPLv3+