The method for making Deno's standard http fileserver monitor files is by using the watchFileSystem option. Here's an example of how to use the fileserver and watchFileSystem options together:
import { serve } from 'https://deno.land/std/http/server.ts';
import { fileServer } from 'https://deno.land/std/http/file_server.ts';
const server = serve({ port: 8000 });
// Serving files
for await (const req of server) {
// The root directory being served
const root = './public';
// Enable file watching and automatic refresh
const fileServerConfig = {
...fileServer(root),
watchFileSystem: true
};
// Serve files with the file server
const requestHandler = fileServer(fileServerConfig);
requestHandler(req);
}
In this example, the file_server will watch the file system for changes and automatically refresh the served files when a change is detected. The watchFileSystem
option is set to true
to enable this behavior.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-16 05:02:46 +0000
Seen: 10 times
Last updated: Jun 16 '23
What steps can be taken to enable http 1.1 persistent connections on the web server?
What are the steps to use .htaccess rules for redirecting all HTTP requests to HTTPS?
What is the procedure for identifying an ajax request with boost::beast?
How can Angular fix the issue whereby the HTTP get request loop produces jumbled data?
What is the process to restrict Google API key using HTTP referrers?
What is a legitimate web address to obtain the Imagenet dataset?
How can I send a pubsub message when a cloud function with http trigger is activated by someone?