Creating Your Own Static Site Host
Learn how to create your own mini version of Netlify, and create your own single-page-app hosting for all your projects.

In this video, I will show you how to create your own mini version of Netlify. It's essentially a single page application host that can serve all of your projects. You will be able to deploy your code to it with a single command.
Here's the Node server code:
const fs = require('fs');
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () =>
console.log(`Example app listening at http://localhost:${port}`),
);
fs.readdir(__dirname + '/projects', function (err, projects) {
projects.forEach((project) => {
app.use(`/${project}`, express.static(`./projects/${project}`));
app.get(`/${project}/*`, (req, res) =>
res.sendFile(
require('path').join(`${__dirname}/projects/${project}/index.html`),
),
);
});
});
Here's the Bash / zsh function:
function deploy () {
ssh root@yourserverip "mkdir -p ~/server/projects/$1" &&
scp -r $2/* root@yourserverip:~/server/projects/$1
}
Usage: deploy url_path static_build_folder