/usr/lib/swipl/library/http/http_files.pl
AllApplicationManualNameSummaryHelp

  • library
    • http
      • http_unix_daemon.pl
      • thread_httpd.pl -- Threaded HTTP server
      • http_wrapper.pl -- Server processing of an HTTP request
      • http_header.pl -- Handling HTTP headers
      • http_stream.pl -- HTTP Streams
      • http_exception.pl -- Map Prolog exceptions to HTTP errors
      • http_path.pl -- Abstract specification of HTTP server locations
      • http_dispatch.pl -- Dispatch requests in the HTTP server
      • http_host.pl
      • http_ssl_plugin.pl
      • http_json.pl -- HTTP JSON Plugin module
      • http_client.pl -- HTTP client library
      • json.pl -- Reading and writing JSON serialization
      • http_open.pl -- HTTP client library
      • http_parameters.pl -- Extract parameters (GET and POST) from HTTP requests
      • http_multipart_plugin.pl -- Multipart form-data plugin
      • http_hook.pl -- HTTP library hooks
      • html_write.pl -- Write HTML text
      • html_quasiquotations.pl -- HTML quasi quotations
      • js_write.pl -- Utilities for including JavaScript
      • js_grammar.pl -- JavaScript grammar
      • http_server_files.pl -- Serve files needed by modules from the server
      • hub.pl -- Manage a hub for websockets
      • websocket.pl -- WebSocket support
      • http_session.pl -- HTTP Session management
      • mimetype.pl -- Determine mime-type for a file
      • http_cors.pl -- Enable CORS: Cross-Origin Resource Sharing
      • html_head.pl -- Automatic inclusion of CSS and scripts links
      • jquery.pl -- Provide JQuery
      • term_html.pl -- Represent Prolog terms as HTML
      • http_dyn_workers.pl -- Dynamically schedule HTTP workers.
      • http_files.pl -- Serve plain files from a hierarchy
        • http_reply_from_files/3
      • http_dirindex.pl -- HTTP directory listings
      • json_convert.pl -- Convert between JSON terms and Prolog application terms
 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'].

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]).
Arguments:
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 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.