Lunch Control

Web Server - Written in Node

Using 100% Node-native libraries: "Filesystem" and "HTTP"

v1.9 ATL





var http = require('http');
var fs = require('fs').promises;

// The desired port number to serve filesystem. 
var port = 42;

http.createServer(function (req, res) {
	if (req.url == "/")
	{
		fs.readFile(__dirname + "/public/index.html")
			.then(contents => {
				res.writeHead(200, {'Content-Type': 'text/html'});
				res.end(contents);
			})
	}
	else
	{
		fs.readFile(__dirname + "/public/" + req.url)
			.then(contents => {
				res.writeHead(200);
				res.end(contents);
			})
			.catch(err => console.log(err))
	}
}).listen(port);



That's it!
For questions: jeremieking@jeremieking.com

Combine it with a reverse proxy (Apache) to host multiple apps!

Copyright © 2026 Jeremie King