Skip to content

Instantly share code, notes, and snippets.

@BlazerYoo
Last active June 17, 2021 23:40
Show Gist options
  • Save BlazerYoo/72ec29c991368c44d0465ff8c8fb32c0 to your computer and use it in GitHub Desktop.
Save BlazerYoo/72ec29c991368c44d0465ff8c8fb32c0 to your computer and use it in GitHub Desktop.
ExpressJs static file server
const express = require('express');
const path = require('path');
const app = express();
const port = 3000;
app.use(express.static(path.join(__dirname + '/files')));
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname + '/files/index.html'));
});
app.listen(port, () => {
console.log(`Express started on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment