Name

logtalk_http_server - Logtalk script for serving a directory over HTTP

Synopsis

logtalk_http_server -v
logtalk_http_server -p prolog [-n port] [directory]
logtalk_http_server -h

Description

logtalk_http_server starts a local HTTP server using the Logtalk http_socket_transport transport. The server listens on the loopback address 127.0.0.1 and serves static files from the selected document root. Requests for directories return HTML directory listings. The server URL is printed after the listener is ready. Stop the server by interrupting the script, usually by typing Control-C.

Options

-v Print script version.

-p Backend Prolog compiler. Required. The following identifiers are used: ECLiPSe - eclipse, SICStus Prolog - sicstus, SWI-Prolog - swi, Trealla Prolog - trealla, and XVM - xvm.

-n Server port. Must be an integer between 1 and 65535. Default is 8080.

-h Provide help on script usage.

Arguments

directory Absolute or relative path to the directory to serve. Default is the current directory.

Exit status

0 The version or help information was printed, or the server terminated normally.

1 An invalid option, backend, port, or document root was specified, or a required integration script or Logtalk driver could not be found.

other Exit status returned by the selected backend Prolog integration script.

Examples

Serve the current directory on the default port using SWI-Prolog: logtalk_http_server -p swi

Serve the relative directory public on port 8000 using Trealla Prolog: logtalk_http_server -p trealla -n 8000 public

Serve an absolute directory path using SICStus Prolog: logtalk_http_server -p sicstus /srv/www

Implementation notes

The ECLiPSe and SICStus Prolog backends serve requests serially without requiring thread support. Backends with thread support use the open-ended server loop provided by the http_server library. Responses close their HTTP connections so that subsequent browser requests can be accepted portably by all supported backends.

The SICStus Prolog integration script is invoked with --noinfo. The SWI-Prolog, Trealla Prolog, and XVM integration scripts are invoked with -q. ECLiPSe does not provide an equivalent quiet option.

The server binds only to the IPv4 loopback address and is not directly reachable from other hosts.

Environment

LOGTALKHOME Specifies the location of the Logtalk installation. The script uses it to locate its Logtalk driver.

LOGTALKUSER Specifies the location of the Logtalk user directory and its scratch directory.

Files

$LOGTALKHOME/scripts/logtalk_http_server.lgt Logtalk source file defining the static-file handler and server loop used by the script.

See also

The Logtalk website at https://logtalk.org/

The Logtalk Handbook at $LOGTALKHOME/docs/handbook/index.html

Author

Paulo Moura <pmoura@logtalk.org>

Copyright

Copyright (c) 1998-2026 Paulo Moura.

This HTML page was made with roffit.