Local Development Server Setup

1 Save this HTML file
2 Start a server using Node.js (recommended)

Install Node.js if you haven't already (download from nodejs.org), then:

Option 1: One-line server (port 3000)

npx serve -l 3000

Option 2: Custom port

Create this as server.js file

const http = require('http');
const fs = require('fs');
const path = require('path');

const port = 3000; // Change this to your preferred port
const server = http.createServer((req, res) => {
    let filePath = '.' + req.url;
    if (filePath === './') filePath = './local-server.html';
    
    fs.readFile(filePath, (err, content) => {
        if (err) {
            res.writeHead(404);
            res.end('File not found');
            return;
        }
        res.writeHead(200);
        res.end(content);
    });
});

server.listen(port, () => {
    console.log(`Server running at http://localhost:${port}/`);
});

Then run:

node server.js

3 Try it now (if using Chrome)

Enter a port number (4000-9999 recommended):

Server output will appear here...
4 Access your server

Once running, open your browser to: