node.js, express.js - What is the easiest way to serve a single static file?

res.sendFile(path_to_file); is all you need; it will automatically set the correct headers and transfer the file (it internally uses the same code as express.static).

In express versions less than 4, use sendfile instead of sendFile.


app.use("/css/myfile.css", express.static(__dirname + '/css/myfile.css'));