New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

serve-here

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serve-here

local static server

latest
Source
npmnpm
Version
3.2.0
Version published
Maintainers
1
Created
Source

#serve-here

Build Status NPM Version NPM Downloads MIT License Dependency Status Coverage Status

NPM

NPM

local static server

everything start from here

feature

  • look up available port automatically, which means multiple instances without specifying port

  • custom routes by scripting here.js

  • live reload

  • support https

  • add ip address to your server, which makes your server available to other devices

  • resolve get, post... every method into local files, for ajax

  • respond files without extension as application/json for ajax

  • open default browser after server launched

  • when the server is on, press enter will open the browser

installation

[sudo] npm install -g serve-here

usage

In your local folder, type here and it goes!

advanced usage

specify port to 8888

here -p 8888

or

here --port 8888

default port is 3000

switch protocol to https

here -S

or

here --ssl

specify server root directory

here -d test

or

here --directory test

default directory is ./

watch file changes, once files changed, reload pages

here -w 3

or

here --watch

default interval is 0 second

recommend to set reload interval to page reload time

do not open the browser

here -s

or

here --silent

output log

here -l

or

here --log 0

middleware support

write here.js in server base directory

let db = {
    tobi: {
        name: 'tobi',
        age: 21
    },
    loki: {
        name: 'loki',
        age: 26
    },
    jane: {
        name: 'jane',
        age: 18
    }
};

module.exports = [
    {
        method: 'get',
        path: '/pets',
        data () {
            let names = Object.keys(db);
            return names.map((name) => {
                return db[name];
            });
        }
    },
    {
        method: 'get',
        path: '/pets/:name',
        data () {
            let name = this.params.name;
            let pet = db[name];
            if (!pet) {
                return {
                    error: `cannot find pet ${name}`
                };
            } else {
                return pet;
            }
        }
    }
];

see koa-router document for more detail

some similar applications

  • puer not support post, respond files without extension as application/octet-stream

  • anywhere not support post, and not support reload

  • browsersync not support post, respond files without extension as application/octet-stream

Keywords

server

FAQs

Package last updated on 21 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts