Learn R Programming

websockets (version 1.1.7)

static_file_service: Serve a static web page from a file.

Description

This utility function closure serves a static web page from a file, checking the file for changes and always serving the most recent copy.

Usage

static_file_service(fn)

Arguments

fn

The file path.

Value

The function returned by this closure must return a valid HTTP response.

Details

A function of two arguments, socket and header is returned. The socket argument indicates the low-level socket descriptor of the websocket client. The header argument contains a parsed HTTP GET request. When invoked, the function may examine the GET request and respond accordingly, usually with a valid HTTP 200 response, or a 40* response indicating an error.

See Also

create_server, static_text_service

Examples

Run this code
# NOT RUN {
# See the detailed example in help('websockets').
# }

Run the code above in your browser using DataLab