Skip to content

Instantly share code, notes, and snippets.

View piboistudios's full-sized avatar
💭
Hacking silex.me, Claude and Go Caddy

Gabriel Hayes piboistudios

💭
Hacking silex.me, Claude and Go Caddy
View GitHub Profile
@piboistudios
piboistudios / server.js
Last active May 2, 2018 04:31
Node.js Server Tailored to Static Webpages with a .html fallback assumption
// I basically made this so that I could divide logical sections of a website into different SPAs for speed without
// serving the entire website up front. This is heavily based on the below article, although I promise I didn't C/P:
// http://adrianmejia.com/blog/2016/08/24/Building-a-Node-js-static-file-server-files-over-HTTP-using-ES6/
const http = require('http');
const port = process.argv[2] || 9000;
http.createServer(function (request, result) {
// import the necessary packages
const url = require('url');
const fs = require('fs');