Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

handle-file

kion2MIT1.0.0

A simple function for serving static files from a "public" folder

handle, file, server, http

readme

handle-file

An example function for servind static files from a "public" folder located in the directory.

Example:

"use strict";

const http = require("http");
const handleFile = require("handle-file");

const server = http.createServer();
server.on("request", handleRequest);
server.listen(8080, handleListen);

function handleRequest(req, res) {

    handleFile(req, res);

}

function handleListen() {

    console.log("Server is listening on port 8080");

}