Node.js quick file server (static files over HTTP)

前端 未结 30 2366
攒了一身酷
攒了一身酷 2020-11-22 12:30

Is there Node.js ready-to-use tool (installed with npm), that would help me expose folder content as file server over HTTP.

Example, if I have



        
30条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 12:56

    Searching in NPM registry https://npmjs.org/search?q=server, I have found static-server https://github.com/maelstrom/static-server

    Ever needed to send a colleague a file, but can't be bothered emailing the 100MB beast? Wanted to run a simple example JavaScript application, but had problems with running it through the file:/// protocol? Wanted to share your media directory at a LAN without setting up Samba, or FTP, or anything else requiring you to edit configuration files? Then this file server will make your life that little bit easier.

    To install the simple static stuff server, use npm:

    npm install -g static-server
    

    Then to serve a file or a directory, simply run

    $ serve path/to/stuff
    Serving path/to/stuff on port 8001
    

    That could even list folder content.

    Unfortunately, it couldn't serve files :)

提交回复
热议问题