Giter VIP home page Giter VIP logo

mirismaili / simplatic-http-server Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 587 KB

A very light-weight and very simple static HTTP server based on node's built-in http module

License: MIT License

JavaScript 63.57% HTML 3.79% TypeScript 31.16% CSS 1.49%
simple-static-http-server simple-http-server very-simple-http-server light-http-server light-weight-http-server too-light-http-server static-http-server http-server server http

simplatic-http-server's Introduction

npm (scoped) Dependencies Status devDependencies Status Known Vulnerabilities install size
Coverage Status
Commitizen friendly GitHub forks GitHub stars
GitHub

Simple Static Http Server

A very light-weight and very simple static HTTP server based on node.js's built-in http module


Installation

npm install simplatic-http-server

Usage

  1. Get access to the main class:

    const StaticServer = require('simplatic-http-server').default

    Or:

    import StaticServer from 'simplatic-http-server'
  2. Instantiate:

    const staticServer = new StaticServer(portNumber /*, servePath = process.cwd() */) 
  3. Listen to portNumber:

    await staticServer.listen(/* onListenCallback, onErrorCallback */)
    
    console.log(`The static server listening on ${portNumber} ...`)

    Or:

    staticServer.listen().then(
    	() => console.log(`The static server listening on ${portNumber} ...`), 
    	err => console.error(err)
    )
  4. Get access to a file in servePath. E. g. type in your browser's address bar: http://127.0.0.1/dir/index.html (Note: The path of index.html must be `${servePath}/dir/index.html` on your local machine).

  5. Turn it off when no more needed:

    await staticServer.shutdown(/* callback */)

simplatic-http-server's People

Contributors

mirismaili avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.