Skip to content

Instantly share code, notes, and snippets.

@samson-sham
Created June 24, 2022 08:05
Show Gist options
  • Save samson-sham/024f2e9259e064b4d359082ed39ab56a to your computer and use it in GitHub Desktop.
Save samson-sham/024f2e9259e064b4d359082ed39ab56a to your computer and use it in GitHub Desktop.
// JavaScript
const webdav = require('webdav-server').v2;
const server = new webdav.WebDAVServer({
port: 1900
});
server.afterRequest((arg, next) => {
// Display the method, the URI, the returned status code and the returned message
console.log('>>', arg.request.method, arg.requested.uri, '>', arg.response.statusCode, arg.response.statusMessage);
// If available, display the body of the response
// console.log(arg.responseBody);
next();
});
server.setFileSystemAsync('/', new webdav.PhysicalFileSystem(process.cwd()))
.then(() => server.start(s => console.log(`READY ${s.address().address}:${s.address().port}`)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment