3.2.0 • Published 8 years ago

serve-here v3.2.0

Weekly downloads
88
License
MIT
Repository
github
Last release
8 years ago

#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

3.2.0

8 years ago

3.1.0

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.7.6

8 years ago

2.7.5

9 years ago

2.7.4

9 years ago

2.7.3

9 years ago

2.7.2

9 years ago

2.6.13

9 years ago

2.6.12

9 years ago

2.6.11

9 years ago

2.6.10

9 years ago

2.6.9

9 years ago

2.6.8

9 years ago

2.6.7

9 years ago

2.6.6

9 years ago

2.6.5

9 years ago

2.6.4

9 years ago

2.6.3

9 years ago

2.6.2

9 years ago

2.6.1

9 years ago

2.6.0

9 years ago

2.5.0

9 years ago

2.4.0

9 years ago

2.3.3

9 years ago

2.3.2

9 years ago

2.3.1

9 years ago

2.3.0

9 years ago

2.2.0

9 years ago

2.1.2

9 years ago

2.1.0

9 years ago

2.0.13

9 years ago

2.0.12

9 years ago

2.0.11

9 years ago

2.0.10

9 years ago

2.0.9

9 years ago

2.0.8

9 years ago

2.0.7

9 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.8.3

9 years ago

1.8.2

9 years ago

1.8.1

9 years ago

1.8.0

9 years ago

1.7.3

9 years ago

1.7.2

9 years ago

1.7.1

9 years ago

1.7.0

9 years ago

1.6.8

9 years ago

1.6.7

9 years ago

1.6.6

9 years ago

1.6.5

9 years ago

1.6.4

9 years ago

1.6.3

9 years ago

1.6.1

9 years ago

1.6.0

9 years ago

1.5.9

9 years ago

1.5.8

9 years ago

1.5.7

9 years ago

1.5.6

9 years ago

1.5.5

9 years ago

1.5.4

9 years ago

1.5.3

9 years ago

1.5.2

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.0

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago