Skip to content

Instantly share code, notes, and snippets.

@krnlde
Last active August 21, 2025 13:59
Show Gist options
  • Select an option

  • Save krnlde/53a2dbf4891902006de9d129ccafc575 to your computer and use it in GitHub Desktop.

Select an option

Save krnlde/53a2dbf4891902006de9d129ccafc575 to your computer and use it in GitHub Desktop.
Express.js streaming static file server
import express from 'express';
import serveIndex from 'serve-index';
const PUBLIC_DIR = '/public';
const PORT = 3000;
const app = express();
app.use(express.static(PUBLIC_DIR), serveIndex(PUBLIC_DIR, { 'icons': true }));
app.listen(PORT, () => {
console.log(`Server is listening on http://localhost:${PORT}/`);
});
{
"type": "module",
"scripts": {
"start": "node index.mjs",
"up": "ncu --interactive --removeRange"
},
"dependencies": {
"express": "5.1.0",
"npm-check-updates": "18.0.2",
"serve-index": "1.9.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment