|Did you know ...||Search Documentation:|
indexesto locate an index file (see below) or uses http_reply_dirindex/3 to create a listing of the directory.
Note that this handler must be tagged as a
http_handler/3 and module
introduction). This also implies that it is possible to override more
specific locations in the hierarchy using http_handler/3
with a longer path-specifier.
|Dir||is either a directory or an path-specification as used by absolute_file_name/3. This option provides great flexibility in (re-)locating the physical files and allows merging the files of multiple physical locations into one web-hierarchy by using multiple user:file_search_path/2 clauses that define the same alias.|
Content-typefrom the file name.
The SWI-Prolog HTTP server doesn't not server static files by default.
You explicitly have to add a handler telling it to do so. The
declarations below tell the server to serve files from the current
/ on the server.
:- use_module(library(http/http_server)). :- use_module(library(http/http_files)). :- http_handler(root(.), http_reply_from_files('.', ), [prefix]).
Now, start the server and visit http://localhost:8080/.
?- http_server([port(localhost:8080)]). % Started server at http://localhost:8080/ true.
localhost:only binds the loopback network, avoiding to expose your website to the outside world.