Skip to content

Instantly share code, notes, and snippets.

View vaidd4's full-sized avatar

David vaidd4

  • France
View GitHub Profile
@vaidd4
vaidd4 / static_server.js
Last active March 14, 2019 15:56 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
const http = require('http')
const url = require('url')
const path = require('path')
const fs = require('fs')
const PORT = parseInt(process.argv[2]) || 8888
http.createServer(function(req, res) {
const uri = url.parse(req.url).pathname
const filename = path.join(process.cwd(), uri)