local-routes

Package that allows access to the localhost using directory-based routes simply and quickly.

Usage no npm install needed!

<script type="module">
  import localRoutes from 'https://cdn.skypack.dev/local-routes';
</script>

README


local-routes

npm installnfo

Table of contents

About

local-routes is a package that allows access to the localhost using directory-based routes simply and quickly.

Installation

Node.js v14.16.1 or newer is recommended.

Install: npm install local-routes

Example usage

Example directory

.
├──index.js
├──package.json
└──/src/
     ├──image.png
     ├──index.html
     └──/directory-a/
          └──file.html

index.js

const localhost = require('local-routes');

localhost.run({dirname: __dirname + "/src"/*, host: "127.0.0.1", port: 8080*/});

In this case, the files will be available in the browser at:

  • http://localhost:3000/image.png
  • http://localhost:3000/index.html
  • http://localhost:3000/directory-a/file.html

Links

Help

If you are experiencing problems, or you just need a nudge in the right direction, please do not hesitate to create a New Issue on Github repository.