• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

3.4 library(http/http_files): Serve plain files from a hierarchy
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog HTTP support
        • The HTTP server libraries
          • library(http/http_files): Serve plain files from a hierarchy
            • http_reply_from_files/3
Availability::- use_module(library(http/http_files)).
http_reply_from_files(+Dir, +Options, +Request)
HTTP handler that serves files from the directory Dir. This handler uses http_reply_file/3 to reply plain files. If the request resolves to a directory, it uses the option indexes to locate an index file (see below) or uses http_reply_dirindex/3 to create a listing of the directory.

Options:

indexes(+List)
List of files tried to find an index for a directory. The default is ['index.html'].
not_found(+Action)
Action defines what happens if the target file was not found. Options: fail makes the handler fail silently. 404 make the handler call http_404/2. Default is fail.

Note that this handler must be tagged as a prefix handler (see 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.

When using http_handler/3 to bind this predicate to an HTTP location, make sure it is bound to a location that ends in a /. When using http:location/3 to define symbolic names to HTTP locations this is written as

:- http_handler(aliasname(.), http_reply_from_files(srcdir, []), [prefix]).
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.
See also
The hookable predicate file_mime_type/2 is used to determine the Content-type from the file name.
ClioPatria (version V3.1.1-51-ga0b30a5)